@Override public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { return tbl.getRowType(relDataTypeFactory); }
@Override public RelNode convert(RelNode rel) { final TableScan scan = (TableScan) rel; int parallelismHint = DEFAULT_PARALLELISM_HINT; final ParallelTable parallelTable = scan.getTable().unwrap(ParallelTable.class); if (parallelTable != null && parallelTable.parallelismHint() != null) { parallelismHint = parallelTable.parallelismHint(); } final Table table = scan.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case STREAM: return new StreamsStreamScanRel(scan.getCluster(), scan.getTraitSet().replace(StreamsLogicalConvention.INSTANCE), scan.getTable(), parallelismHint); default: throw new IllegalArgumentException(String.format("Unsupported table type: %s", table.getJdbcTableType())); } } }
@Override public Statistic getStatistic() { return tbl.getStatistic(); }
/** * Visit the tables in the given schema. The * @param schemaPath the path to the given schema * @param schema the given schema */ public void visitTables(String schemaPath, SchemaPlus schema) { final AbstractSchema drillSchema = schema.unwrap(AbstractSchema.class); final List<String> tableNames = Lists.newArrayList(schema.getTableNames()); for(Pair<String, ? extends Table> tableNameToTable : drillSchema.getTablesByNames(tableNames)) { final String tableName = tableNameToTable.getKey(); final Table table = tableNameToTable.getValue(); final TableType tableType = table.getJdbcTableType(); // Visit the table, and if requested ... if(shouldVisitTable(schemaPath, tableName, tableType) && visitTable(schemaPath, tableName, table)) { // ... do for each of the table's fields. final RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl(DRILL_REL_DATATYPE_SYSTEM)); for (RelDataTypeField field: tableRow.getFieldList()) { if (shouldVisitColumn(schemaPath, tableName, field.getName())) { visitField(schemaPath, tableName, field); } } } } }
private boolean isRolledUpColumn(SqlIdentifier identifier, SqlValidatorScope scope) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return false; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.isRolledUp(columnName); } return false; }
private boolean isRolledUpColumnAllowedInAgg(SqlIdentifier identifier, SqlValidatorScope scope, SqlCall aggCall, SqlNode parent) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return true; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.rolledUpColumnValidInsideAgg(columnName, aggCall, parent, catalogReader.getConfig()); } return true; }
private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight) { leftOrRight = stripAs(leftOrRight); // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else. if (leftOrRight instanceof SqlIdentifier) { SqlIdentifier from = (SqlIdentifier) leftOrRight; Table table = findTable(catalogReader.getRootSchema(), Util.last(from.names), catalogReader.nameMatcher().isCaseSensitive()); String name = Util.last(identifier.names); if (table != null && table.isRolledUp(name)) { throw newValidationError(identifier, RESOURCE.rolledUpNotAllowed(name, "USING")); } } }
private boolean isRolledUpColumnAllowedInAgg(SqlIdentifier identifier, SqlValidatorScope scope, SqlCall aggCall, SqlNode parent) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return true; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.rolledUpColumnValidInsideAgg(columnName, aggCall, parent, catalogReader.getConfig()); } return true; }
.from(table.getRowType(typeFactory).getFieldList()) .transform( new Function<RelDataTypeField, Object[]>()
switch (table.getJdbcTableType()) { case STREAM: if (operation != TableModify.Operation.INSERT) { updateColumnList, sourceExpressionList, flattened, primaryKey); default: throw new IllegalArgumentException(String.format("Unsupported table type: %s", table.getJdbcTableType()));
@Override public Statistic getStatistic() { return tbl.getStatistic(); }
private boolean isRolledUpColumn(SqlIdentifier identifier, SqlValidatorScope scope) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return false; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.isRolledUp(columnName); } return false; }
private boolean isRolledUpColumnAllowedInAgg(SqlIdentifier identifier, SqlValidatorScope scope, SqlCall aggCall, SqlNode parent) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return true; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.rolledUpColumnValidInsideAgg(columnName, aggCall, parent, catalogReader.getConfig()); } return true; }
if (modifiableViewTable != null && source instanceof SqlCall) { final Table table = modifiableViewTable.unwrap(Table.class); final RelDataType tableRowType = table.getRowType(typeFactory); final List<RelDataTypeField> tableFields = tableRowType.getFieldList();
public void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id) { // Resolve identifier as a table. final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolveTable(id.names, catalogReader.nameMatcher(), SqlValidatorScope.Path.EMPTY, resolved); if (resolved.count() != 1) { throw newValidationError(id, RESOURCE.tableNameNotFound(id.toString())); } // We've found a table. But is it a sequence? final SqlValidatorNamespace ns = resolved.only().namespace; if (ns instanceof TableNamespace) { final Table table = ns.getTable().unwrap(Table.class); switch (table.getJdbcTableType()) { case SEQUENCE: case TEMPORARY_SEQUENCE: return; } } throw newValidationError(id, RESOURCE.notASequence(id.toString())); }
public List<RelReferentialConstraint> getReferentialConstraints() { if (table != null) { return table.getStatistic().getReferentialConstraints(); } return ImmutableList.of(); }
private boolean isRolledUpColumn(SqlIdentifier identifier, SqlValidatorScope scope) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return false; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.isRolledUp(columnName); } return false; }
if (modifiableViewTable != null) { final Table table = modifiableViewTable.unwrap(Table.class); final RelDataType tableRowType = table.getRowType(typeFactory);
CalciteMetaTable(Table calciteTable, String tableCat, String tableSchem, String tableName) { super(tableCat, tableSchem, tableName, calciteTable.getJdbcTableType().jdbcName); this.calciteTable = Objects.requireNonNull(calciteTable); } }
public double getRowCount() { if (rowCount != null) { return rowCount; } if (table != null) { final Double rowCount = table.getStatistic().getRowCount(); if (rowCount != null) { return rowCount; } } return 100d; }