MCPcopy Create free account
hub / github.com/apache/calcite / run

Method run

core/src/main/java/org/apache/calcite/tools/RelRunners.java:38–58  ·  view source on GitHub ↗

Runs a relational expression by creating a JDBC connection.

(RelNode rel)

Source from the content-addressed store, hash-verified

36
37 /** Runs a relational expression by creating a JDBC connection. */
38 public static PreparedStatement run(RelNode rel) {
39 final RelShuttle shuttle = new RelHomogeneousShuttle() {
40 @Override public RelNode visit(TableScan scan) {
41 final RelOptTable table = scan.getTable();
42 if (scan instanceof LogicalTableScan
43 && Bindables.BindableTableScan.canHandle(table)) {
44 // Always replace the LogicalTableScan with BindableTableScan
45 // because it's implementation does not require a "schema" as context.
46 return Bindables.BindableTableScan.create(scan.getCluster(), table);
47 }
48 return super.visit(scan);
49 }
50 };
51 rel = rel.accept(shuttle);
52 try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
53 final RelRunner runner = connection.unwrap(RelRunner.class);
54 return runner.prepareStatement(rel);
55 } catch (SQLException e) {
56 throw Util.throwAsRuntime(e);
57 }
58 }
59}

Callers 4

testRunValuesMethod · 0.95
testRunMethod · 0.95
dumpMethod · 0.95

Calls 5

prepareStatementMethod · 0.95
throwAsRuntimeMethod · 0.95
acceptMethod · 0.65
getConnectionMethod · 0.65
unwrapMethod · 0.65

Tested by 4

testRunValuesMethod · 0.76
testRunMethod · 0.76
dumpMethod · 0.76