Java Code Examples for org.apache.calcite.avatica.ColumnMetaData#StructType

The following examples show how to use org.apache.calcite.avatica.ColumnMetaData#StructType . 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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 vote down vote up
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: QuarkResultSet.java    From quark with Apache License 2.0 5 votes vote down vote up
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 6
Source File: CalciteResultSet.java    From calcite with Apache License 2.0 5 votes vote down vote up
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 7
Source File: DremioMetaImpl.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
protected static ColumnMetaData.StructType fieldMetaData(Class<?> clazz) {
  return MetaImpl.fieldMetaData(clazz);
}