OmniSciDB  72c90bc290
 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 749 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

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

Definition at line 750 of file HeavyDBSqlOperatorTable.java.

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

Member Function Documentation

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

Definition at line 772 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 767 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 760 of file HeavyDBSqlOperatorTable.java.

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

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