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

Public Member Functions

 MLPredict ()
 
RelDataType inferReturnType (SqlOperatorBinding opBinding)
 
SqlOperandCountRange getOperandCountRange ()
 
boolean checkOperandTypes (SqlCallBinding callBinding, boolean throwOnFailure)
 

Detailed Description

Definition at line 747 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

com.mapd.calcite.parser.HeavyDBSqlOperatorTable.MLPredict.MLPredict ( )
inline

Definition at line 748 of file HeavyDBSqlOperatorTable.java.

748  {
749  super("ML_PREDICT",
750  SqlKind.OTHER_FUNCTION,
751  null,
752  null,
753  null,
754  SqlFunctionCategory.SYSTEM);
755  }

Member Function Documentation

boolean com.mapd.calcite.parser.HeavyDBSqlOperatorTable.MLPredict.checkOperandTypes ( SqlCallBinding  callBinding,
boolean  throwOnFailure 
)
inline

Definition at line 770 of file HeavyDBSqlOperatorTable.java.

770  {
771  // A call to ML_PREDICT can take the following arguemnts
772  // 1. A text literal with the model name - REQUIRED
773  // 2. Any number of optional text column arguments
774  // 3. Any number of numeric arguments
775  final SqlValidator validator = callBinding.getValidator();
776 
777  final int num_operands = callBinding.getOperandCount();
778  if (num_operands < 2) {
779  throw new IllegalArgumentException(
780  "At least 2 arguments are required, the model name and one or more predictors.");
781  }
782  for (int operand_idx = 0; operand_idx < num_operands; operand_idx++) {
783  final SqlNode operand = callBinding.operand(operand_idx);
784  final SqlTypeName operand_type =
785  validator.getValidatedNodeType(operand).getSqlTypeName();
786  final SqlTypeFamily operand_type_family = operand_type.getFamily();
787  if (operand_idx == 0) {
788  if (!operand.isA(EnumSet.of(SqlKind.LITERAL))
789  || operand_type_family != SqlTypeFamily.CHARACTER) {
790  throw new IllegalArgumentException(
791  "First argument must be TEXT literal denoting the model name.");
792  }
793  } else {
794  if (operand.isA(EnumSet.of(SqlKind.LITERAL))) {
795  throw new IllegalArgumentException(
796  "Literals are not supported as predictors.");
797  }
798  if (!(operand_type_family == SqlTypeFamily.NUMERIC
799  || operand_type_family == SqlTypeFamily.CHARACTER)) {
800  throw new IllegalArgumentException(
801  "Only TEXT and NUMERIC predictors are supported.");
802  }
803  }
804  }
805  return true;
806  }
SqlOperandCountRange com.mapd.calcite.parser.HeavyDBSqlOperatorTable.MLPredict.getOperandCountRange ( )
inline

Definition at line 765 of file HeavyDBSqlOperatorTable.java.

765  {
766  return SqlOperandCountRanges.from(2);
767  }
RelDataType com.mapd.calcite.parser.HeavyDBSqlOperatorTable.MLPredict.inferReturnType ( SqlOperatorBinding  opBinding)
inline

Definition at line 758 of file HeavyDBSqlOperatorTable.java.

758  {
759  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
760  return typeFactory.createTypeWithNullability(
761  typeFactory.createSqlType(SqlTypeName.DOUBLE), /*nullable=*/true);
762  }

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