OmniSciDB  72180abbfe
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
org.apache.calcite.prepare.MapDPlanner Class Reference
+ Inheritance diagram for org.apache.calcite.prepare.MapDPlanner:
+ Collaboration diagram for org.apache.calcite.prepare.MapDPlanner:

Classes

class  CompletionResult
 

Public Member Functions

 MapDPlanner (FrameworkConfig config)
 
void advanceToValidate ()
 
void ready ()
 
CompletionResult getCompletionHints (final String sql, final int cursor, final List< String > visibleTables)
 
RelRoot rel (SqlNode sql)
 
void setFilterPushDownInfo (final List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo)
 

Package Attributes

FrameworkConfig config
 

Private Member Functions

CalciteCatalogReader createCatalogReader ()
 
RelRoot applyFilterPushdown (RelRoot root)
 
RelRoot applyQueryOptimizationRules (RelRoot root)
 

Static Private Member Functions

static SchemaPlus rootSchema (SchemaPlus schema)
 

Private Attributes

List
< MapDParserOptions.FilterPushDownInfo > 
filterPushDownInfo
 

Detailed Description

Customised version of the PlannerImpl for MapD. Used to be a copy of PlannerImpl, refactored now to use inheritance to minimize maintenance efforts. Implementation of org.apache.calcite.tools.Planner.

Definition at line 61 of file MapDPlanner.java.

Constructor & Destructor Documentation

org.apache.calcite.prepare.MapDPlanner.MapDPlanner ( FrameworkConfig  config)
inline

Definition at line 66 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config.

66  {
67  super(config);
68  this.config = config;
69  }

Member Function Documentation

void org.apache.calcite.prepare.MapDPlanner.advanceToValidate ( )
inline

Definition at line 110 of file MapDPlanner.java.

110  {
111  try {
112  String dummySql = "SELECT 1";
113  super.parse(dummySql);
114  } catch (SqlParseException e) {
115  throw new RuntimeException(e);
116  }
117  }
RelRoot org.apache.calcite.prepare.MapDPlanner.applyFilterPushdown ( RelRoot  root)
inlineprivate

Definition at line 165 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo.

Referenced by org.apache.calcite.prepare.MapDPlanner.rel().

165  {
166  if (filterPushDownInfo.isEmpty()) {
167  return root;
168  }
169  final DynamicFilterJoinRule dynamicFilterJoinRule = new DynamicFilterJoinRule(true,
170  RelFactories.LOGICAL_BUILDER,
171  FilterJoinRule.TRUE_PREDICATE,
173  final HepProgram program =
174  HepProgram.builder().addRuleInstance(dynamicFilterJoinRule).build();
175  HepPlanner prePlanner = new HepPlanner(program);
176  prePlanner.setRoot(root.rel);
177  final RelNode rootRelNode = prePlanner.findBestExp();
178  filterPushDownInfo.clear();
179  return root.withRel(rootRelNode);
180  }
List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo

+ Here is the caller graph for this function:

RelRoot org.apache.calcite.prepare.MapDPlanner.applyQueryOptimizationRules ( RelRoot  root)
inlineprivate

Definition at line 182 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.rel().

182  {
183  QueryOptimizationRules outerJoinOptRule =
184  new OuterJoinOptViaNullRejectionRule(RelFactories.LOGICAL_BUILDER);
185 
186  HepProgram opt_program =
187  HepProgram.builder().addRuleInstance(outerJoinOptRule).build();
188  HepPlanner prePlanner = new HepPlanner(
189  opt_program, null, true, Functions.ignore2(), RelOptCostImpl.FACTORY);
190  prePlanner.setRoot(root.rel);
191  final RelNode rootRelNode = prePlanner.findBestExp();
192  return root.withRel(rootRelNode);
193  }

+ Here is the caller graph for this function:

CalciteCatalogReader org.apache.calcite.prepare.MapDPlanner.createCatalogReader ( )
inlineprivate

Definition at line 90 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config, and org.apache.calcite.prepare.MapDPlanner.rootSchema().

Referenced by org.apache.calcite.prepare.MapDPlanner.getCompletionHints().

90  {
91  final SchemaPlus rootSchema = rootSchema(config.getDefaultSchema());
92  final Context context = config.getContext();
93  final CalciteConnectionConfig connectionConfig;
94 
95  if (context != null) {
96  connectionConfig = context.unwrap(CalciteConnectionConfig.class);
97  } else {
98  Properties properties = new Properties();
99  properties.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(),
100  String.valueOf(config.getParserConfig().caseSensitive()));
101  connectionConfig = new CalciteConnectionConfigImpl(properties);
102  }
103 
104  return new CalciteCatalogReader(CalciteSchema.from(rootSchema),
105  CalciteSchema.from(config.getDefaultSchema()).path(null),
106  getTypeFactory(),
107  connectionConfig);
108  }
static SchemaPlus rootSchema(SchemaPlus schema)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CompletionResult org.apache.calcite.prepare.MapDPlanner.getCompletionHints ( final String  sql,
final int  cursor,
final List< String >  visibleTables 
)
inline

Definition at line 137 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config, org.apache.calcite.prepare.MapDPlanner.createCatalogReader(), and org.apache.calcite.prepare.MapDPlanner.ready().

138  {
139  ready();
140 
141  SqlValidator.Config validatorConfig = SqlValidator.Config.DEFAULT;
142  validatorConfig = validatorConfig.withSqlConformance(SqlConformanceEnum.LENIENT);
143 
144  MapDSqlAdvisorValidator advisor_validator = new MapDSqlAdvisorValidator(visibleTables,
145  config.getOperatorTable(),
147  getTypeFactory(),
148  validatorConfig);
149  SqlAdvisor advisor = new MapDSqlAdvisor(advisor_validator);
150  String[] replaced = new String[1];
151  int adjusted_cursor = cursor < 0 ? sql.length() : cursor;
152  java.util.List<SqlMoniker> hints =
153  advisor.getCompletionHints(sql, adjusted_cursor, replaced);
154  return new CompletionResult(hints, replaced[0]);
155  }
CalciteCatalogReader createCatalogReader()

+ Here is the call graph for this function:

void org.apache.calcite.prepare.MapDPlanner.ready ( )
inline

Definition at line 119 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.getCompletionHints().

119  {
120  // need to call ready on the super class, but that method is marked private
121  // circumventing via reflection for now
122  try {
123  Method readyMethod = getClass().getSuperclass().getDeclaredMethod("ready");
124  readyMethod.setAccessible(true);
125  readyMethod.invoke(this);
126  } catch (InvocationTargetException e) {
127  if (e.getCause() instanceof RuntimeException) {
128  throw(RuntimeException) e.getCause();
129  } else {
130  throw new RuntimeException(e.getCause());
131  }
132  } catch (Exception e) {
133  throw new RuntimeException(e);
134  }
135  }

+ Here is the caller graph for this function:

RelRoot org.apache.calcite.prepare.MapDPlanner.rel ( SqlNode  sql)
inline

Definition at line 158 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.applyFilterPushdown(), and org.apache.calcite.prepare.MapDPlanner.applyQueryOptimizationRules().

158  {
159  RelRoot root = super.rel(sql);
160  root = applyQueryOptimizationRules(root);
161  root = applyFilterPushdown(root);
162  return root;
163  }
RelRoot applyQueryOptimizationRules(RelRoot root)
RelRoot applyFilterPushdown(RelRoot root)

+ Here is the call graph for this function:

static SchemaPlus org.apache.calcite.prepare.MapDPlanner.rootSchema ( SchemaPlus  schema)
inlinestaticprivate

Definition at line 71 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.createCatalogReader().

71  {
72  for (;;) {
73  if (schema.getParentSchema() == null) {
74  return schema;
75  }
76  schema = schema.getParentSchema();
77  }
78  }

+ Here is the caller graph for this function:

void org.apache.calcite.prepare.MapDPlanner.setFilterPushDownInfo ( final List< MapDParserOptions.FilterPushDownInfo >  filterPushDownInfo)
inline

Definition at line 195 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo.

196  {
197  this.filterPushDownInfo = filterPushDownInfo;
198  }
List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo

Member Data Documentation

List<MapDParserOptions.FilterPushDownInfo> org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo
private

The documentation for this class was generated from the following file: