Java Code Examples for org.apache.calcite.avatica.ColumnMetaData#AvaticaType
The following examples show how to use
org.apache.calcite.avatica.ColumnMetaData#AvaticaType .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalciteResultSet.java From Quicksql with MIT License | 6 votes |
@Override public ResultSet create(ColumnMetaData.AvaticaType elementType, Iterable<Object> iterable) throws SQLException { final List<ColumnMetaData> columnMetaDataList; if (elementType instanceof ColumnMetaData.StructType) { columnMetaDataList = ((ColumnMetaData.StructType) elementType).columns; } else { columnMetaDataList = ImmutableList.of(ColumnMetaData.dummy(elementType, false)); } final CalcitePrepare.CalciteSignature signature = (CalcitePrepare.CalciteSignature) this.signature; final CalcitePrepare.CalciteSignature<Object> newSignature = new CalcitePrepare.CalciteSignature<>(signature.sql, signature.parameters, signature.internalParameters, signature.rowType, columnMetaDataList, Meta.CursorFactory.ARRAY, signature.rootSchema, ImmutableList.of(), -1, null, statement.getStatementType()); ResultSetMetaData subResultSetMetaData = new AvaticaResultSetMetaData(statement, null, newSignature); final CalciteResultSet resultSet = new CalciteResultSet(statement, signature, subResultSetMetaData, localCalendar.getTimeZone(), new Meta.Frame(0, true, iterable)); final Cursor cursor = resultSet.createCursor(elementType, iterable); return resultSet.execute2(cursor, columnMetaDataList); }
Example 2
Source File: QuarkResultSet.java From quark with Apache License 2.0 | 6 votes |
@Override public ResultSet create(ColumnMetaData.AvaticaType elementType, Iterable<Object> iterable) { final List<ColumnMetaData> columnMetaDataList; if (elementType instanceof ColumnMetaData.StructType) { columnMetaDataList = ((ColumnMetaData.StructType) elementType).columns; } else { columnMetaDataList = ImmutableList.of(ColumnMetaData.dummy(elementType, false)); } final CalcitePrepare.CalciteSignature signature = (CalcitePrepare.CalciteSignature) this.signature; final CalcitePrepare.CalciteSignature<Object> newSignature = new CalcitePrepare.CalciteSignature<>(signature.sql, signature.parameters, signature.internalParameters, signature.rowType, columnMetaDataList, Meta.CursorFactory.ARRAY, signature.rootSchema, ImmutableList.<RelCollation>of(), -1, null); ResultSetMetaData subResultSetMetaData = new AvaticaResultSetMetaData(statement, null, newSignature); final QuarkResultSet resultSet = new QuarkResultSet(statement, signature, subResultSetMetaData, localCalendar.getTimeZone(), new Meta.Frame(0, true, iterable)); final Cursor cursor = resultSet.createCursor(elementType, iterable); return resultSet.execute2(cursor, columnMetaDataList); }
Example 3
Source File: CalciteResultSet.java From calcite with Apache License 2.0 | 6 votes |
@Override public ResultSet create(ColumnMetaData.AvaticaType elementType, Iterable<Object> iterable) throws SQLException { final List<ColumnMetaData> columnMetaDataList; if (elementType instanceof ColumnMetaData.StructType) { columnMetaDataList = ((ColumnMetaData.StructType) elementType).columns; } else { columnMetaDataList = ImmutableList.of(ColumnMetaData.dummy(elementType, false)); } final CalcitePrepare.CalciteSignature signature = (CalcitePrepare.CalciteSignature) this.signature; final CalcitePrepare.CalciteSignature<Object> newSignature = new CalcitePrepare.CalciteSignature<>(signature.sql, signature.parameters, signature.internalParameters, signature.rowType, columnMetaDataList, Meta.CursorFactory.ARRAY, signature.rootSchema, ImmutableList.of(), -1, null, statement.getStatementType()); ResultSetMetaData subResultSetMetaData = new AvaticaResultSetMetaData(statement, null, newSignature); final CalciteResultSet resultSet = new CalciteResultSet(statement, signature, subResultSetMetaData, localCalendar.getTimeZone(), new Meta.Frame(0, true, iterable)); final Cursor cursor = resultSet.createCursor(elementType, iterable); return resultSet.execute2(cursor, columnMetaDataList); }
Example 4
Source File: CalciteResultSet.java From Quicksql with MIT License | 5 votes |
private Cursor createCursor(ColumnMetaData.AvaticaType elementType, Iterable iterable) { final Enumerator enumerator = Linq4j.iterableEnumerator(iterable); //noinspection unchecked return !(elementType instanceof ColumnMetaData.StructType) || ((ColumnMetaData.StructType) elementType).columns.size() == 1 ? new ObjectEnumeratorCursor(enumerator) : new ArrayEnumeratorCursor(enumerator); }
Example 5
Source File: CalcitePrepareImpl.java From Quicksql with MIT License | 5 votes |
private ColumnMetaData metaData(JavaTypeFactory typeFactory, int ordinal, String fieldName, RelDataType type, RelDataType fieldType, List<String> origins) { final ColumnMetaData.AvaticaType avaticaType = avaticaType(typeFactory, type, fieldType); return new ColumnMetaData( ordinal, false, true, false, false, type.isNullable() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls, true, type.getPrecision(), fieldName, origin(origins, 0), origin(origins, 2), getPrecision(type), getScale(type), origin(origins, 1), null, avaticaType, true, false, false, avaticaType.columnClassName()); }
Example 6
Source File: CalcitePrepareImpl.java From Quicksql with MIT License | 5 votes |
private ColumnMetaData.AvaticaType avaticaType(JavaTypeFactory typeFactory, RelDataType type, RelDataType fieldType) { final String typeName = getTypeName(type); if (type.getComponentType() != null) { final ColumnMetaData.AvaticaType componentType = avaticaType(typeFactory, type.getComponentType(), null); final Type clazz = typeFactory.getJavaClass(type.getComponentType()); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.array(componentType, typeName, rep); } else { int typeOrdinal = getTypeOrdinal(type); switch (typeOrdinal) { case Types.STRUCT: final List<ColumnMetaData> columns = new ArrayList<>(); for (RelDataTypeField field : type.getFieldList()) { columns.add( metaData(typeFactory, field.getIndex(), field.getName(), field.getType(), null, null)); } return ColumnMetaData.struct(columns); case ExtraSqlTypes.GEOMETRY: typeOrdinal = Types.VARCHAR; // fall through default: final Type clazz = typeFactory.getJavaClass(Util.first(fieldType, type)); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.scalar(typeOrdinal, typeName, rep); } } }
Example 7
Source File: AbstractCursor.java From calcite-avatica with Apache License 2.0 | 5 votes |
public ArrayAccessor(Getter getter, ColumnMetaData.AvaticaType componentType, Accessor componentAccessor, SlotGetter componentSlotGetter, ArrayImpl.Factory factory) { super(getter); this.componentType = componentType; this.componentAccessor = componentAccessor; this.componentSlotGetter = componentSlotGetter; this.factory = factory; }
Example 8
Source File: QuarkResultSet.java From quark with Apache License 2.0 | 5 votes |
private Cursor createCursor(ColumnMetaData.AvaticaType elementType, Iterable iterable) { final Enumerator enumerator = Linq4j.iterableEnumerator(iterable); //noinspection unchecked return !(elementType instanceof ColumnMetaData.StructType) || ((ColumnMetaData.StructType) elementType).columns.size() == 1 ? new ObjectEnumeratorCursor(enumerator) : new ArrayEnumeratorCursor(enumerator); }
Example 9
Source File: PlanExecutor.java From quark with Apache License 2.0 | 5 votes |
private ColumnMetaData metaData(JavaTypeFactory typeFactory, int ordinal, String fieldName, RelDataType type, RelDataType fieldType, List<String> origins) { final ColumnMetaData.AvaticaType avaticaType = avaticaType(typeFactory, type, fieldType); return new ColumnMetaData( ordinal, false, true, false, false, type.isNullable() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls, true, type.getPrecision(), fieldName, origin(origins, 0), origin(origins, 2), getPrecision(type), getScale(type), origin(origins, 1), null, avaticaType, true, false, false, avaticaType.columnClassName()); }
Example 10
Source File: PlanExecutor.java From quark with Apache License 2.0 | 5 votes |
private ColumnMetaData.AvaticaType avaticaType(JavaTypeFactory typeFactory, RelDataType type, RelDataType fieldType) { final String typeName = getTypeName(type); if (type.getComponentType() != null) { final ColumnMetaData.AvaticaType componentType = avaticaType(typeFactory, type.getComponentType(), null); final Type clazz = typeFactory.getJavaClass(type.getComponentType()); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.array(componentType, typeName, rep); } else { final int typeOrdinal = getTypeOrdinal(type); switch (typeOrdinal) { case Types.STRUCT: final List<ColumnMetaData> columns = new ArrayList<>(); for (RelDataTypeField field : type.getFieldList()) { columns.add( metaData(typeFactory, field.getIndex(), field.getName(), field.getType(), null, null)); } return ColumnMetaData.struct(columns); default: final Type clazz = typeFactory.getJavaClass(Util.first(fieldType, type)); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.scalar(typeOrdinal, typeName, rep); } } }
Example 11
Source File: CalciteResultSet.java From calcite with Apache License 2.0 | 5 votes |
private Cursor createCursor(ColumnMetaData.AvaticaType elementType, Iterable iterable) { final Enumerator enumerator = Linq4j.iterableEnumerator(iterable); //noinspection unchecked return !(elementType instanceof ColumnMetaData.StructType) || ((ColumnMetaData.StructType) elementType).columns.size() == 1 ? new ObjectEnumeratorCursor(enumerator) : new ArrayEnumeratorCursor(enumerator); }
Example 12
Source File: CalcitePrepareImpl.java From calcite with Apache License 2.0 | 5 votes |
private ColumnMetaData metaData(JavaTypeFactory typeFactory, int ordinal, String fieldName, RelDataType type, RelDataType fieldType, List<String> origins) { final ColumnMetaData.AvaticaType avaticaType = avaticaType(typeFactory, type, fieldType); return new ColumnMetaData( ordinal, false, true, false, false, type.isNullable() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls, true, type.getPrecision(), fieldName, origin(origins, 0), origin(origins, 2), getPrecision(type), getScale(type), origin(origins, 1), null, avaticaType, true, false, false, avaticaType.columnClassName()); }
Example 13
Source File: CalcitePrepareImpl.java From calcite with Apache License 2.0 | 5 votes |
private ColumnMetaData.AvaticaType avaticaType(JavaTypeFactory typeFactory, RelDataType type, RelDataType fieldType) { final String typeName = getTypeName(type); if (type.getComponentType() != null) { final ColumnMetaData.AvaticaType componentType = avaticaType(typeFactory, type.getComponentType(), null); final Type clazz = typeFactory.getJavaClass(type.getComponentType()); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.array(componentType, typeName, rep); } else { int typeOrdinal = getTypeOrdinal(type); switch (typeOrdinal) { case Types.STRUCT: final List<ColumnMetaData> columns = new ArrayList<>(type.getFieldList().size()); for (RelDataTypeField field : type.getFieldList()) { columns.add( metaData(typeFactory, field.getIndex(), field.getName(), field.getType(), null, null)); } return ColumnMetaData.struct(columns); case ExtraSqlTypes.GEOMETRY: typeOrdinal = Types.VARCHAR; // fall through default: final Type clazz = typeFactory.getJavaClass(Util.first(fieldType, type)); final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz); assert rep != null; return ColumnMetaData.scalar(typeOrdinal, typeName, rep); } } }
Example 14
Source File: StructImpl.java From calcite-avatica with Apache License 2.0 | 4 votes |
ResultSet create(ColumnMetaData.AvaticaType elementType, Iterable<Object> iterable);
Example 15
Source File: ArrayImpl.java From calcite-avatica with Apache License 2.0 | 2 votes |
/** * Creates a {@link ResultSet} from the given list of values per {@link Array#getResultSet()}. * * @param elementType The type of the elements * @param iterable The elements * @throws SQLException on error */ ResultSet create(ColumnMetaData.AvaticaType elementType, Iterable<Object> iterable) throws SQLException;
Example 16
Source File: ArrayImpl.java From calcite-avatica with Apache License 2.0 | 2 votes |
/** * Creates an {@link Array} from the given list of values, converting any primitive values * into the corresponding objects. * * @param elementType The type of the elements * @param elements The elements */ Array createArray(ColumnMetaData.AvaticaType elementType, Iterable<Object> elements);