public ColumnBasedSet(TableSchema schema) { descriptors = schema.toTypeDescriptors(); columns = new ArrayList<ColumnBuffer>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new ColumnBuffer(colDesc.getType())); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
@Test public void testGetFunctions() throws Exception { SessionHandle sessionHandle = client.openSession("tom", "password"); assertNotNull(sessionHandle); OperationHandle opHandle = client.getFunctions(sessionHandle, null, null, "*"); TableSchema schema = client.getResultSetMetadata(opHandle); ColumnDescriptor columnDesc = schema.getColumnDescriptorAt(0); assertEquals("FUNCTION_CAT", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(1); assertEquals("FUNCTION_SCHEM", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(2); assertEquals("FUNCTION_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(3); assertEquals("REMARKS", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(4); assertEquals("FUNCTION_TYPE", columnDesc.getName()); assertEquals(Type.INT_TYPE, columnDesc.getType()); columnDesc = schema.getColumnDescriptorAt(5); assertEquals("SPECIFIC_NAME", columnDesc.getName()); assertEquals(Type.STRING_TYPE, columnDesc.getType()); // Cleanup client.closeOperation(opHandle); client.closeSession(sessionHandle); }
public Type[] toTypes() { Type[] types = new Type[columns.size()]; for (int i = 0; i < types.length; i++) { types[i] = columns.get(i).getType(); } return types; }
public Type[] toTypes() { Type[] types = new Type[columns.size()]; for (int i = 0; i < types.length; i++) { types[i] = columns.get(i).getType(); } return types; }
public Type[] toTypes() { Type[] types = new Type[columns.size()]; for (int i = 0; i < types.length; i++) { types[i] = columns.get(i).getType(); } return types; }
public Type[] toTypes() { Type[] types = new Type[columns.size()]; for (int i = 0; i < types.length; i++) { types[i] = columns.get(i).getType(); } return types; }
public ColumnBasedSet(TableSchema schema) { types = schema.toTypes(); columns = new ArrayList<Column>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new Column(colDesc.getType())); } }
public ColumnBasedSet(TableSchema schema) { descriptors = schema.toTypeDescriptors(); columns = new ArrayList<ColumnBuffer>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new ColumnBuffer(colDesc.getType())); } }
public ColumnBasedSet(TableSchema schema) { types = schema.toTypes(); columns = new ArrayList<Column>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new Column(colDesc.getType())); } }
public ColumnBasedSet(TableSchema schema) { types = schema.toTypes(); columns = new ArrayList<Column>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new Column(colDesc.getType())); } }
public ColumnBasedSet(TableSchema schema) { types = schema.toTypes(); columns = new ArrayList<Column>(); for (ColumnDescriptor colDesc : schema.getColumnDescriptors()) { columns.add(new Column(colDesc.getType())); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
private Object getColumnValue(int columnIndex) throws SQLException { if (row == null) { throw new SQLException("No row found."); } if (row.length == 0) { throw new SQLException("RowSet does not contain any columns!"); } if (columnIndex > row.length) { throw new SQLException("Invalid columnIndex: " + columnIndex); } Type columnType = getSchema().getColumnDescriptorAt(columnIndex - 1).getType(); try { Object evaluated = evaluate(columnType, row[columnIndex - 1]); wasNull = evaluated == null; return evaluated; } catch (Exception e) { e.printStackTrace(); throw new SQLException("Unrecognized column type:" + columnType, e); } }
/** * To query result set metadata. * * @return the query result set metadata */ public QueryResultSetMetadata toQueryResultSetMetadata() { List<ResultColumn> result = new ArrayList<ResultColumn>(); for (ColumnDescriptor col : getColumns()) { result.add(new ResultColumn(col.getName(), col.getType().getName())); } return new QueryResultSetMetadata(result); }
/** * To query result set metadata. * * @return the query result set metadata */ public QueryResultSetMetadata toQueryResultSetMetadata() { List<ResultColumn> result = new ArrayList<ResultColumn>(); for (ColumnDescriptor col : getColumns()) { result.add(new ResultColumn(col.getName(), col.getType().getName())); } return new QueryResultSetMetadata(result); }
@Override public void serialize(ColumnDescriptor columnDescriptor, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("name", columnDescriptor.getName()); jsonGenerator.writeStringField("comment", columnDescriptor.getComment()); jsonGenerator.writeNumberField("position", columnDescriptor.getOrdinalPosition()); jsonGenerator.writeStringField("type", columnDescriptor.getType().getName()); jsonGenerator.writeEndObject(); } });
@Override public void serialize(ColumnDescriptor columnDescriptor, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("name", columnDescriptor.getName()); jsonGenerator.writeStringField("comment", columnDescriptor.getComment()); jsonGenerator.writeNumberField("position", columnDescriptor.getOrdinalPosition()); jsonGenerator.writeStringField("type", columnDescriptor.getType().getName()); jsonGenerator.writeEndObject(); } });