Java Code Examples for org.apache.calcite.plan.Contexts#of()

The following examples show how to use org.apache.calcite.plan.Contexts#of() . 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: PlanningConfigurationBuilder.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanningConfigurationBuilder(
		TableConfig tableConfig,
		FunctionCatalog functionCatalog,
		CalciteSchema rootSchema,
		ExpressionBridge<PlannerExpression> expressionBridge) {
	this.tableConfig = tableConfig;
	this.functionCatalog = functionCatalog;

	// the converter is needed when calling temporal table functions from SQL, because
	// they reference a history table represented with a tree of table operations
	this.context = Contexts.of(expressionBridge);

	this.planner = new VolcanoPlanner(costFactory, context);
	planner.setExecutor(new ExpressionReducer(tableConfig));
	planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

	this.expressionBridge = expressionBridge;

	this.rootSchema = rootSchema;
}
 
Example 2
Source File: PlanningConfigurationBuilder.java    From flink with Apache License 2.0 6 votes vote down vote up
public PlanningConfigurationBuilder(
		TableConfig tableConfig,
		FunctionCatalog functionCatalog,
		CalciteSchema rootSchema,
		ExpressionBridge<PlannerExpression> expressionBridge) {
	this.tableConfig = tableConfig;
	this.functionCatalog = functionCatalog;

	// the converter is needed when calling temporal table functions from SQL, because
	// they reference a history table represented with a tree of table operations.
	this.context = Contexts.of(expressionBridge, tableConfig);

	this.planner = new VolcanoPlanner(costFactory, context);
	planner.setExecutor(new ExpressionReducer(tableConfig));
	planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

	this.expressionBridge = expressionBridge;

	this.rootSchema = rootSchema;
}
 
Example 3
Source File: SqlToRelConverterTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-2323">[CALCITE-2323]
 * Validator should allow alternative nullCollations for ORDER BY in
 * OVER</a>. */
@Test void testUserDefinedOrderByOver() {
  String sql = "select deptno,\n"
      + "  rank() over(partition by empno order by deptno)\n"
      + "from emp\n"
      + "order by row_number() over(partition by empno order by deptno)";
  Properties properties = new Properties();
  properties.setProperty(
      CalciteConnectionProperty.DEFAULT_NULL_COLLATION.camelName(),
      NullCollation.LOW.name());
  CalciteConnectionConfigImpl connectionConfig =
      new CalciteConnectionConfigImpl(properties);
  TesterImpl tester = new TesterImpl(getDiffRepos(), false, false, true, false, true,
      null, null, SqlToRelConverter.Config.DEFAULT,
      SqlConformanceEnum.DEFAULT, Contexts.of(connectionConfig));
  sql(sql).with(tester).ok();
}
 
Example 4
Source File: PlannerContext.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a configured {@link FlinkRelBuilder} for a planning session.
 *
 * @param currentCatalog the current default catalog to look for first during planning.
 * @param currentDatabase the current default database to look for first during planning.
 * @return configured rel builder
 */
public FlinkRelBuilder createRelBuilder(String currentCatalog, String currentDatabase) {
	FlinkCalciteCatalogReader relOptSchema = createCatalogReader(
			false,
			currentCatalog,
			currentDatabase);

	Context chain = Contexts.of(
		context,
		// Sets up the ViewExpander explicitly for FlinkRelBuilder.
		createFlinkPlanner(currentCatalog, currentDatabase).createToRelContext()
	);
	return new FlinkRelBuilder(chain, cluster, relOptSchema);
}