use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptCluster in project hive by apache.
the class TestRelSignature method before.
@Before
public void before() {
HepProgramBuilder programBuilder = new HepProgramBuilder();
programBuilder.addRuleInstance(new HivePointLookupOptimizerRule.FilterCondition(2));
planner = new HepPlanner(programBuilder.build());
JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl();
RexBuilder rexBuilder = new RexBuilder(typeFactory);
final RelOptCluster optCluster = RelOptCluster.create(planner, rexBuilder);
RelDataType rowTypeMock = typeFactory.createStructType(MyRecord.class);
LogicalTableScan tableScan = LogicalTableScan.create(optCluster, tableMock, Collections.emptyList());
doReturn(tableScan).when(tableMock).toRel(ArgumentMatchers.any());
doReturn(rowTypeMock).when(tableMock).getRowType();
doReturn(tableMock).when(schemaMock).getTableForMember(Matchers.any());
lenient().doReturn(hiveTableMDMock).when(tableMock).getHiveTableMD();
builder = HiveRelFactories.HIVE_BUILDER.create(optCluster, schemaMock);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptCluster in project beam by apache.
the class ExpressionConverter method retrieveRexNodeFromOrderByScan.
/**
* Extract expressions from order by scan node.
*/
public List<RexNode> retrieveRexNodeFromOrderByScan(RelOptCluster cluster, ResolvedOrderByScan node, List<RelDataTypeField> fieldList) {
final RexBuilder rexBuilder = cluster.getRexBuilder();
List<RexNode> ret = new ArrayList<>();
for (ResolvedColumn column : node.getColumnList()) {
int index = indexOfProjectionColumnRef(column.getId(), node.getInputScan().getColumnList());
ret.add(rexBuilder.makeInputRef(fieldList.get(index).getType(), index));
}
return ret;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptCluster in project beam by apache.
the class ZetaSQLPlannerImpl method rel.
public RelRoot rel(String sql, QueryParameters params) {
RelOptCluster cluster = RelOptCluster.create(planner, new RexBuilder(typeFactory));
AnalyzerOptions options = SqlAnalyzer.getAnalyzerOptions(params, defaultTimezone);
BeamZetaSqlCatalog catalog = BeamZetaSqlCatalog.create(defaultSchemaPlus, (JavaTypeFactory) cluster.getTypeFactory(), options);
// Set up table providers that need to be pre-registered
SqlAnalyzer analyzer = new SqlAnalyzer();
List<List<String>> tables = analyzer.extractTableNames(sql, options);
TableResolution.registerTables(this.defaultSchemaPlus, tables);
QueryTrait trait = new QueryTrait();
catalog.addTables(tables, trait);
ResolvedQueryStmt statement = analyzer.analyzeQuery(sql, options, catalog);
ExpressionConverter expressionConverter = new ExpressionConverter(cluster, params, catalog.getUserFunctionDefinitions());
ConversionContext context = ConversionContext.of(config, expressionConverter, cluster, trait);
RelNode convertedNode = QueryStatementConverter.convertRootQuery(context, statement);
return RelRoot.of(convertedNode, SqlKind.ALL);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptCluster in project flink by apache.
the class HiveParserUtils method genValuesRelNode.
// creates LogicalValues node
public static RelNode genValuesRelNode(RelOptCluster cluster, RelDataType rowType, List<List<RexLiteral>> rows) {
List<Object> immutableRows = rows.stream().map(HiveParserUtils::toImmutableList).collect(Collectors.toList());
Class[] argTypes = new Class[] { RelOptCluster.class, RelDataType.class, null };
if (useShadedImmutableList) {
argTypes[2] = HiveParserUtils.shadedImmutableListClz;
} else {
argTypes[2] = HiveParserUtils.immutableListClz;
}
Method method = HiveReflectionUtils.tryGetMethod(LogicalValues.class, "create", argTypes);
Preconditions.checkState(method != null, "Cannot get the method to create LogicalValues");
try {
return (RelNode) method.invoke(null, cluster, rowType, HiveParserUtils.toImmutableList(immutableRows));
} catch (IllegalAccessException | InvocationTargetException e) {
throw new FlinkHiveException("Failed to create LogicalValues", e);
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelOptCluster in project calcite by apache.
the class EnumerableSort method create.
/**
* Creates an EnumerableSort.
*/
public static EnumerableSort create(RelNode child, RelCollation collation, RexNode offset, RexNode fetch) {
final RelOptCluster cluster = child.getCluster();
final RelTraitSet traitSet = cluster.traitSetOf(EnumerableConvention.INSTANCE).replace(collation);
return new EnumerableSort(cluster, traitSet, child, collation, offset, fetch);
}
Aggregations