Java Code Examples for org.apache.calcite.avatica.Meta#Signature
The following examples show how to use
org.apache.calcite.avatica.Meta#Signature .
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: CalciteConnectionImpl.java From Quicksql with MIT License | 6 votes |
private CalcitePreparedStatement prepareStatement_( CalcitePrepare.Query<?> query, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { try { final Meta.Signature signature = parseQuery(query, createPrepareContext(), -1); final CalcitePreparedStatement calcitePreparedStatement = (CalcitePreparedStatement) factory.newPreparedStatement(this, null, signature, resultSetType, resultSetConcurrency, resultSetHoldability); server.getStatement(calcitePreparedStatement.handle).setSignature(signature); return calcitePreparedStatement; } catch (Exception e) { throw Helper.INSTANCE.createException( "Error while preparing statement [" + query.sql + "]", e); } }
Example 2
Source File: CalciteJdbc41Factory.java From Quicksql with MIT License | 5 votes |
public CalciteResultSet newResultSet(AvaticaStatement statement, QueryState state, Meta.Signature signature, TimeZone timeZone, Meta.Frame firstFrame) throws SQLException { final ResultSetMetaData metaData = newResultSetMetaData(statement, signature); final CalcitePrepare.CalciteSignature calciteSignature = (CalcitePrepare.CalciteSignature) signature; return new CalciteResultSet(statement, calciteSignature, metaData, timeZone, firstFrame); }
Example 3
Source File: AbstractService.java From calcite-avatica with Apache License 2.0 | 5 votes |
Meta.StatementHandle finagle(Meta.StatementHandle h) { final Meta.Signature signature = finagle(h.signature); if (signature == h.signature) { return h; } return new Meta.StatementHandle(h.connectionId, h.id, signature); }
Example 4
Source File: DremioJdbc41Factory.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public DremioResultSetImpl newResultSet(AvaticaStatement statement, QueryState state, Meta.Signature signature, TimeZone timeZone, Meta.Frame firstFrame) throws SQLException { final ResultSetMetaData metaData = newResultSetMetaData(statement, signature); return new DremioResultSetImpl(statement, state, signature, metaData, timeZone, firstFrame); }
Example 5
Source File: QuarkMetaResultSet.java From quark with Apache License 2.0 | 5 votes |
protected QuarkMetaResultSet(String connectionId, int statementId, boolean ownStatement, Meta.Signature signature, Meta.Frame firstFrame, long updateCount) { super(connectionId, statementId, ownStatement, signature, firstFrame, updateCount); }
Example 6
Source File: DremioPreparedStatementImpl.java From dremio-oss with Apache License 2.0 | 5 votes |
protected DremioPreparedStatementImpl(DremioConnectionImpl connection, StatementHandle h, Meta.Signature signature, PreparedStatement preparedStatementHandle, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { super(connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); connection.openStatementsRegistry.addStatement(this); this.preparedStatementHandle = preparedStatementHandle; if (preparedStatementHandle != null) { ((DremioColumnMetaDataList) signature.columns).updateColumnMetaData(preparedStatementHandle.getColumnsList()); } }
Example 7
Source File: JdbcResultSet.java From calcite-avatica with Apache License 2.0 | 5 votes |
/** Creates a result set with maxRowCount. * * <p>If {@code maxRowCount} is -2 ({@link JdbcMeta#UNLIMITED_COUNT}), * returns an unlimited number of rows in a single frame; any other * negative value (typically -1) returns an unlimited number of rows * in frames of the default frame size. */ public static JdbcResultSet create(String connectionId, int statementId, ResultSet resultSet, int maxRowCount) { try { Meta.Signature sig = JdbcMeta.signature(resultSet.getMetaData()); return create(connectionId, statementId, resultSet, maxRowCount, sig); } catch (SQLException e) { throw new RuntimeException(e); } }
Example 8
Source File: KylinConnection.java From kylin with Apache License 2.0 | 5 votes |
Signature mockPreparedSignature(String sql) { List<AvaticaParameter> params = new ArrayList<AvaticaParameter>(); int startIndex = 0; while (sql.indexOf("?", startIndex) >= 0) { AvaticaParameter param = new AvaticaParameter(false, 0, 0, 0, null, null, null); params.add(param); startIndex = sql.indexOf("?", startIndex) + 1; } ArrayList<ColumnMetaData> columns = new ArrayList<ColumnMetaData>(); Map<String, Object> internalParams = Collections.<String, Object> emptyMap(); return new Meta.Signature(columns, sql, params, internalParams, CursorFactory.ARRAY, Meta.StatementType.SELECT); }
Example 9
Source File: QuicksqlResultSet.java From Quicksql with MIT License | 5 votes |
/** * Creates a QuicksqlResultSet. */ public QuicksqlResultSet(AvaticaStatement statement, Meta.Signature calciteSignature, ResultSetMetaData resultSetMetaData, TimeZone timeZone, Meta.Frame firstFrame) throws SQLException { super(statement, null, calciteSignature, resultSetMetaData, timeZone, firstFrame); }
Example 10
Source File: JdbcResultSet.java From calcite-avatica with Apache License 2.0 | 4 votes |
/** Creates a frame containing a given number or unlimited number of rows * from a result set. */ static Meta.Frame frame(StatementInfo info, ResultSet resultSet, long offset, int fetchMaxRowCount, Calendar calendar, Optional<Meta.Signature> sig) throws SQLException { final ResultSetMetaData metaData = resultSet.getMetaData(); final int columnCount = metaData.getColumnCount(); final int[] types = new int[columnCount]; Set<Integer> arrayOffsets = new HashSet<>(); for (int i = 0; i < types.length; i++) { types[i] = metaData.getColumnType(i + 1); if (Types.ARRAY == types[i]) { arrayOffsets.add(i); } } final List<Object> rows = new ArrayList<>(); // Meta prepare/prepareAndExecute 0 return 0 row and done boolean done = fetchMaxRowCount == 0; for (int i = 0; fetchMaxRowCount < 0 || i < fetchMaxRowCount; i++) { final boolean hasRow; if (null != info) { hasRow = info.next(); } else { hasRow = resultSet.next(); } if (!hasRow) { done = true; resultSet.close(); break; } Object[] columns = new Object[columnCount]; for (int j = 0; j < columnCount; j++) { columns[j] = getValue(resultSet, types[j], j, calendar); if (arrayOffsets.contains(j)) { // If we have an Array type, our Signature is lacking precision. We can't extract the // component type of an Array from metadata, we have to update it as we're serializing // the ResultSet. final Array array = resultSet.getArray(j + 1); // Only attempt to determine the component type for the array when non-null if (null != array && sig.isPresent()) { ColumnMetaData columnMetaData = sig.get().columns.get(j); ArrayType arrayType = (ArrayType) columnMetaData.type; SqlType componentSqlType = SqlType.valueOf(array.getBaseType()); // Avatica Server will always return non-primitives to ensure nullable is guaranteed. ColumnMetaData.Rep rep = ColumnMetaData.Rep.serialRepOf(componentSqlType); AvaticaType componentType = ColumnMetaData.scalar(array.getBaseType(), array.getBaseTypeName(), rep); // Update the ArrayType from the Signature arrayType.updateComponentType(componentType); // We only need to update the array's type once. arrayOffsets.remove(j); } } } rows.add(columns); } return new Meta.Frame(offset, done, rows); }
Example 11
Source File: CalciteJdbc41Factory.java From calcite with Apache License 2.0 | 4 votes |
public ResultSetMetaData newResultSetMetaData(AvaticaStatement statement, Meta.Signature signature) { return new AvaticaResultSetMetaData(statement, null, signature); }
Example 12
Source File: JdbcResultSet.java From calcite-avatica with Apache License 2.0 | 4 votes |
protected JdbcResultSet(String connectionId, int statementId, boolean ownStatement, Meta.Signature signature, Meta.Frame firstFrame) { this(connectionId, statementId, ownStatement, signature, firstFrame, -1L); }
Example 13
Source File: QuarkResultSet.java From quark with Apache License 2.0 | 4 votes |
QuarkResultSet(AvaticaStatement statement, Meta.Signature signature, ResultSetMetaData resultSetMetaData, TimeZone timeZone, Meta.Frame firstFrame) { super(statement, null, signature, resultSetMetaData, timeZone, firstFrame); }
Example 14
Source File: CalciteConnectionImpl.java From calcite with Apache License 2.0 | 4 votes |
public void setSignature(Meta.Signature signature) { this.signature = signature; }
Example 15
Source File: QuarkJdbc41Factory.java From quark with Apache License 2.0 | 4 votes |
@Override public ResultSetMetaData newResultSetMetaData(AvaticaStatement statement, Meta.Signature signature) { return new AvaticaResultSetMetaData(statement, null, signature); }
Example 16
Source File: PlanExecutor.java From quark with Apache License 2.0 | 4 votes |
private QuarkMetaResultSet getMetaResultSetFromIterator(Iterator<Object> iterator, QuarkConnectionImpl connection, ParserResult result, String sql, QuarkJdbcStatement stmt, Meta.StatementHandle h, long maxRowCount, Class clazz) throws SQLException { QuarkMetaResultSet metaResultSet; final JavaTypeFactory typeFactory = connection.getSqlQueryParser().getTypeFactory(); final RelDataType x; switch (result.getKind()) { case INSERT: case EXPLAIN: x = RelOptUtil.createDmlRowType(result.getKind(), typeFactory); break; case OTHER_DDL: x = getRowType(clazz); break; default: x = result.getRelNode().getRowType(); } RelDataType jdbcType = makeStruct(typeFactory, x); final List<ColumnMetaData> columns = getColumnMetaDataList(typeFactory, x, jdbcType); Meta.Signature signature = new Meta.Signature(columns, sql, new ArrayList<AvaticaParameter>(), new HashMap<String, Object>(), Meta.CursorFactory.ARRAY, Meta.StatementType.SELECT); stmt.setSignature(signature); stmt.setResultSet(iterator); if (signature.statementType.canUpdate()) { metaResultSet = QuarkMetaResultSet.count(h.connectionId, h.id, ((Number) iterator.next()).intValue()); } else { metaResultSet = QuarkMetaResultSet.create(h.connectionId, h.id, iterator, maxRowCount, signature); } return metaResultSet; }
Example 17
Source File: QuarkJdbcStatementImpl.java From quark with Apache License 2.0 | 4 votes |
public Meta.Signature getSignature() { return signature; }
Example 18
Source File: CalciteJdbc41Factory.java From Quicksql with MIT License | 4 votes |
public ResultSetMetaData newResultSetMetaData(AvaticaStatement statement, Meta.Signature signature) { return new AvaticaResultSetMetaData(statement, null, signature); }
Example 19
Source File: QuarkJdbcStatement.java From quark with Apache License 2.0 | votes |
void setSignature(Meta.Signature signature);
Example 20
Source File: CalciteServerStatement.java From calcite with Apache License 2.0 | votes |
void setSignature(Meta.Signature signature);