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

Public Member Functions

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

Detailed Description

Definition at line 811 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

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

Definition at line 812 of file HeavyDBSqlOperatorTable.java.

812  {
813  super("PCA_PROJECT",
814  SqlKind.OTHER_FUNCTION,
815  null,
816  null,
817  null,
818  SqlFunctionCategory.SYSTEM);
819  }

Member Function Documentation

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

Definition at line 834 of file HeavyDBSqlOperatorTable.java.

834  {
835  // A call to PCA_PROJECT can take the following arguemnts
836  // 1. A text literal with the model name - REQUIRED
837  // 2. Any number of optional text column arguments
838  // 3. Any number of numeric arguments
839  // 4. A numeric literal with the nth principal component to project to
840  final SqlValidator validator = callBinding.getValidator();
841 
842  final int num_operands = callBinding.getOperandCount();
843  if (num_operands < 3) {
844  throw new IllegalArgumentException(
845  "At least 3 arguments are required, the model name, one or more features, and the nth principal component to project to.");
846  }
847  for (int operand_idx = 0; operand_idx < num_operands; operand_idx++) {
848  final SqlNode operand = callBinding.operand(operand_idx);
849  final SqlTypeName operand_type =
850  validator.getValidatedNodeType(operand).getSqlTypeName();
851  final SqlTypeFamily operand_type_family = operand_type.getFamily();
852  if (operand_idx == 0) {
853  if (!operand.isA(EnumSet.of(SqlKind.LITERAL))
854  || operand_type_family != SqlTypeFamily.CHARACTER) {
855  throw new IllegalArgumentException(
856  "First argument must be TEXT literal denoting the model name.");
857  }
858  } else if (operand_idx < num_operands - 1) {
859  if (operand.isA(EnumSet.of(SqlKind.LITERAL))) {
860  throw new IllegalArgumentException("Literals are not supported as features.");
861  }
862  if (!(operand_type_family == SqlTypeFamily.NUMERIC
863  || operand_type_family == SqlTypeFamily.CHARACTER)) {
864  throw new IllegalArgumentException(
865  "Only TEXT and NUMERIC features are supported.");
866  }
867  } else if (!operand.isA(EnumSet.of(SqlKind.LITERAL))
868  || !(operand_type_family == SqlTypeFamily.NUMERIC)
869  || !(operand_type.equals(SqlTypeName.INTEGER))) {
870  throw new IllegalArgumentException(
871  "Last argument to PCA_PROJECT expects integer literal dimension index.");
872  }
873  }
874  return true;
875  }
SqlOperandCountRange com.mapd.calcite.parser.HeavyDBSqlOperatorTable.PCAProject.getOperandCountRange ( )
inline

Definition at line 829 of file HeavyDBSqlOperatorTable.java.

829  {
830  return SqlOperandCountRanges.from(3);
831  }
RelDataType com.mapd.calcite.parser.HeavyDBSqlOperatorTable.PCAProject.inferReturnType ( SqlOperatorBinding  opBinding)
inline

Definition at line 822 of file HeavyDBSqlOperatorTable.java.

822  {
823  final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
824  return typeFactory.createTypeWithNullability(
825  typeFactory.createSqlType(SqlTypeName.DOUBLE), /*nullable=*/true);
826  }

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