OmniSciDB  f17484ade4
 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 809 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

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

Definition at line 810 of file HeavyDBSqlOperatorTable.java.

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

Member Function Documentation

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

Definition at line 832 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 827 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 820 of file HeavyDBSqlOperatorTable.java.

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

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