OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction Class Reference
+ Inheritance diagram for com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction:
+ Collaboration diagram for com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction:

Public Member Functions

List< String > getParamNames ()
 
List< FunctionParameter > getParameters ()
 
SqlReturnTypeInference getRowTypeInference ()
 
Set< RelColumnMapping > getColumnMappings ()
 

Package Functions

 ExtTableFunction (final String name, final ExtensionFunction sig)
 

Private Member Functions

void debugPrint (String msg, Boolean debugMode)
 

Private Attributes

final List< SqlTypeFamily > arg_types
 
final List< SqlTypeName > outs
 
final List< String > arg_names
 
final List< String > pretty_arg_names
 
final List< String > out_names
 
final Map< String, String > options
 

Detailed Description

Definition at line 2368 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.ExtTableFunction ( final String  name,
final ExtensionFunction  sig 
)
inlinepackage

Definition at line 2369 of file HeavyDBSqlOperatorTable.java.

References com.mapd.parser.server.ExtensionFunction.toSqlSignature().

2369  {
2370  super(name,
2371  SqlKind.OTHER_FUNCTION,
2372  ReturnTypes.CURSOR,
2373  null,
2374  OperandTypes.family(sig.toSqlSignature()),
2375  SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
2376  arg_types = sig.toSqlSignature();
2377  outs = sig.getSqlOuts();
2378  out_names = sig.getOutNames();
2379  arg_names = sig.getArgNames();
2380  // pretty_arg_names will be same as arg_names, except with
2381  // arg names for cursors stripped of array elements, i.e
2382  // my_cursor_input[x, y, z] => my_cursor_input
2383  pretty_arg_names = sig.getPrettyArgNames();
2384  options = sig.getOptions();
2385  }
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

Member Function Documentation

void com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.debugPrint ( String  msg,
Boolean  debugMode 
)
inlineprivate

Definition at line 2449 of file HeavyDBSqlOperatorTable.java.

2449  {
2450  if (debugMode) {
2451  System.out.println(msg);
2452  }
2453  }
Set<RelColumnMapping> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getColumnMappings ( )
inline

Definition at line 2455 of file HeavyDBSqlOperatorTable.java.

References Integer.

2455  {
2456  final Boolean debugMode = false;
2457  Set<RelColumnMapping> s = new HashSet<RelColumnMapping>();
2458  debugPrint("getNameAsId() -> " + getNameAsId() + ", arg_names=" + arg_names
2459  + ", out_names=" + out_names,
2460  debugMode);
2461  if (Integer.valueOf(options.getOrDefault("filter_table_function_transpose", "0"))
2462  == 1) {
2463  debugPrint("getNameAsId() -> " + getNameAsId(), debugMode);
2464  int rel_idx = -1;
2465  for (int arg_idx = 0; arg_idx < arg_names.size(); ++arg_idx) {
2466  String arg_name = arg_names.get(arg_idx);
2467  String[] fields;
2468  int start = arg_name.indexOf("[");
2469  if (start != -1) {
2470  rel_idx += 1;
2471  int end = arg_name.lastIndexOf("]");
2472  fields = arg_name.substring(start + 1, end)
2473  .replaceAll("\\s+", "")
2474  .split(",", 0);
2475  } else {
2476  fields = new String[] {arg_name};
2477  }
2478  debugPrint("fields=" + Arrays.toString(fields), debugMode);
2479  for (int field_idx = 0; field_idx < fields.length; ++field_idx) {
2480  int out_idx = out_names.indexOf(fields[field_idx]);
2481  if (out_idx >= 0) {
2482  s.add(new RelColumnMapping(out_idx, rel_idx, field_idx, false));
2483  debugPrint("out_idx, arg_idx/rel_idx, field_idx=" + out_idx + ", " + arg_idx
2484  + "/" + rel_idx + ", " + field_idx,
2485  debugMode);
2486  }
2487  }
2488  }
2489  }
2490  return s;
2491  }
List<FunctionParameter> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getParameters ( )
inline

Definition at line 2407 of file HeavyDBSqlOperatorTable.java.

2407  {
2408  final Boolean has_names = this.pretty_arg_names != null
2409  && this.pretty_arg_names.size() == this.arg_types.size();
2410  final List<FunctionParameter> parameters = new java.util.ArrayList<>();
2411  for (int i = 0; i < this.arg_types.size(); i++) {
2412  final int arg_idx = i;
2413  parameters.add(new FunctionParameter() {
2414  public int getOrdinal() {
2415  return arg_idx;
2416  }
2417 
2418  public String getName() {
2419  if (has_names) {
2420  return pretty_arg_names.get(arg_idx);
2421  }
2422  return "arg" + arg_idx;
2423  }
2424 
2425  public RelDataType getType(RelDataTypeFactory typeFactory) {
2426  return arg_types.get(arg_idx).getDefaultConcreteType(typeFactory);
2427  }
2428 
2429  public boolean isOptional() {
2430  return false;
2431  }
2432  });
2433  }
2434  return parameters;
2435  }
List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getParamNames ( )
inline

Definition at line 2393 of file HeavyDBSqlOperatorTable.java.

SqlReturnTypeInference com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getRowTypeInference ( )
inline

Definition at line 2438 of file HeavyDBSqlOperatorTable.java.

2438  {
2439  return opBinding -> {
2440  FieldInfoBuilder ret = opBinding.getTypeFactory().builder();
2441  for (int out_idx = 0; out_idx < outs.size(); ++out_idx) {
2442  ret = ret.add(out_names.get(out_idx), outs.get(out_idx));
2443  ret = ret.nullable(true);
2444  }
2445  return ret.build();
2446  };
2447  }

Member Data Documentation

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.arg_names
private

Definition at line 2495 of file HeavyDBSqlOperatorTable.java.

final List<SqlTypeFamily> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.arg_types
private

Definition at line 2493 of file HeavyDBSqlOperatorTable.java.

final Map<String, String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.options
private

Definition at line 2498 of file HeavyDBSqlOperatorTable.java.

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.out_names
private

Definition at line 2497 of file HeavyDBSqlOperatorTable.java.

final List<SqlTypeName> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.outs
private

Definition at line 2494 of file HeavyDBSqlOperatorTable.java.

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.pretty_arg_names
private

Definition at line 2496 of file HeavyDBSqlOperatorTable.java.


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