OmniSciDB  a5dc49c757
 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 754 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

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

Definition at line 755 of file HeavyDBSqlOperatorTable.java.

755  {
756  super("ML_PREDICT",
757  SqlKind.OTHER_FUNCTION,
758  null,
759  null,
760  null,
761  SqlFunctionCategory.SYSTEM);
762  }

Member Function Documentation

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

Definition at line 777 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 772 of file HeavyDBSqlOperatorTable.java.

772  {
773  return SqlOperandCountRanges.from(2);
774  }
RelDataType com.mapd.calcite.parser.HeavyDBSqlOperatorTable.MLPredict.inferReturnType ( SqlOperatorBinding  opBinding)
inline

Definition at line 765 of file HeavyDBSqlOperatorTable.java.

765  {
766  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
767  return typeFactory.createTypeWithNullability(
768  typeFactory.createSqlType(SqlTypeName.DOUBLE), /*nullable=*/true);
769  }

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