Java Code Examples for org.apache.calcite.jdbc.CalcitePrepare#AnalyzeViewResult
The following examples show how to use
org.apache.calcite.jdbc.CalcitePrepare#AnalyzeViewResult .
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: Schemas.java From calcite with Apache License 2.0 | 6 votes |
/** Analyzes a view. For use within Calcite only. */ public static CalcitePrepare.AnalyzeViewResult analyzeView( final CalciteConnection connection, final CalciteSchema schema, final List<String> schemaPath, final String viewSql, List<String> viewPath, boolean fail) { final CalcitePrepare prepare = CalcitePrepare.DEFAULT_FACTORY.apply(); final ImmutableMap<CalciteConnectionProperty, String> propValues = ImmutableMap.of(); final CalcitePrepare.Context context = makeContext(connection, schema, schemaPath, viewPath, propValues); CalcitePrepare.Dummy.push(context); try { return prepare.analyzeView(context, viewSql, fail); } finally { CalcitePrepare.Dummy.pop(context); } }
Example 2
Source File: ViewTableMacro.java From calcite with Apache License 2.0 | 6 votes |
public TranslatableTable apply(List<Object> arguments) { final CalciteConnection connection = MaterializedViewTable.MATERIALIZATION_CONNECTION; CalcitePrepare.AnalyzeViewResult parsed = Schemas.analyzeView(connection, schema, schemaPath, viewSql, viewPath, modifiable != null && modifiable); final List<String> schemaPath1 = schemaPath != null ? schemaPath : schema.path(null); if ((modifiable == null || modifiable) && parsed.modifiable && parsed.table != null) { return modifiableViewTable(parsed, viewSql, schemaPath1, viewPath, schema); } else { return viewTable(parsed, viewSql, schemaPath1, viewPath); } }
Example 3
Source File: ViewTableMacro.java From calcite with Apache License 2.0 | 5 votes |
/** Allows a sub-class to return an extension of {@link ModifiableViewTable} * by overriding this method. */ protected ModifiableViewTable modifiableViewTable(CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath, CalciteSchema schema) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new ModifiableViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath, parsed.table, Schemas.path(schema.root(), parsed.tablePath), parsed.constraint, parsed.columnMapping); }
Example 4
Source File: ViewTableMacro.java From calcite with Apache License 2.0 | 5 votes |
/** Allows a sub-class to return an extension of {@link ViewTable} by * overriding this method. */ protected ViewTable viewTable(CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new ViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath); }
Example 5
Source File: MockCatalogReader.java From calcite with Apache License 2.0 | 5 votes |
@Override protected ModifiableViewTable modifiableViewTable( CalcitePrepare.AnalyzeViewResult parsed, String viewSql, List<String> schemaPath, List<String> viewPath, CalciteSchema schema) { final JavaTypeFactory typeFactory = (JavaTypeFactory) parsed.typeFactory; final Type elementType = typeFactory.getJavaClass(parsed.rowType); return new MockModifiableViewTable(elementType, RelDataTypeImpl.proto(parsed.rowType), viewSql, schemaPath, viewPath, parsed.table, Schemas.path(schema.root(), parsed.tablePath), parsed.constraint, parsed.columnMapping); }