Tabnine Logo
OperandTypes
Code IndexAdd Tabnine to your IDE (free)

How to use
OperandTypes
in
org.apache.calcite.sql.type

Best Java code snippets using org.apache.calcite.sql.type.OperandTypes (Showing top 20 results out of 315)

origin: apache/incubator-druid

 public SqlFunction build()
 {
  return new SqlFunction(
    name,
    kind,
    Preconditions.checkNotNull(returnTypeInference, "returnTypeInference"),
    null,
    OperandTypes.family(
      Preconditions.checkNotNull(operandTypes, "operandTypes"),
      i -> i + 1 > requiredOperands
    ),
    functionCategory
  );
 }
}
origin: apache/incubator-druid

 QuantileSqlAggFunction()
 {
  super(
    NAME,
    null,
    SqlKind.OTHER_FUNCTION,
    ReturnTypes.explicit(SqlTypeName.DOUBLE),
    null,
    OperandTypes.or(
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE1, OperandTypes.ANY, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC)
      ),
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE2, OperandTypes.ANY, OperandTypes.LITERAL, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC, SqlTypeFamily.EXACT_NUMERIC)
      )
    ),
    SqlFunctionCategory.NUMERIC,
    false,
    false
  );
 }
}
origin: dremio/dremio-oss

public SqlDatePartOperator() {
 super(
   "DATE_PART",
   SqlKind.OTHER_FUNCTION,
   ReturnTypes.BIGINT_NULLABLE,
   null,
   OperandTypes.sequence(
     "<PERIOD LITERAL>, <DATE or TIMESTAMP or INTERVAL>",
     new EnumeratedListChecker(VALID_PERIODS.keySet()),
     OperandTypes.or(
       OperandTypes.family(SqlTypeFamily.DATE),
       OperandTypes.family(SqlTypeFamily.TIMESTAMP),
       OperandTypes.family(SqlTypeFamily.DATETIME),
       OperandTypes.family(SqlTypeFamily.DATETIME_INTERVAL),
       OperandTypes.family(SqlTypeFamily.INTERVAL_DAY_TIME),
       OperandTypes.family(SqlTypeFamily.INTERVAL_YEAR_MONTH))
     ),
     SqlFunctionCategory.SYSTEM);
}
origin: Qihoo360/Quicksql

private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) {
 switch (operandType.getSqlTypeName()) {
 case ARRAY:
  return OperandTypes.family(SqlTypeFamily.INTEGER);
 case MAP:
  return OperandTypes.family(
    operandType.getKeyType().getSqlTypeName().getFamily());
 case ANY:
 case DYNAMIC_STAR:
  return OperandTypes.or(
    OperandTypes.family(SqlTypeFamily.INTEGER),
    OperandTypes.family(SqlTypeFamily.CHARACTER));
 default:
  throw new AssertionError(operandType.getSqlTypeName());
 }
}
origin: Qihoo360/Quicksql

public SqlFloorFunction(SqlKind kind) {
 super(kind.name(), kind, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
   OperandTypes.or(OperandTypes.NUMERIC_OR_INTERVAL,
     OperandTypes.sequence(
       "'" + kind + "(<DATE> TO <TIME_UNIT>)'\n"
       + "'" + kind + "(<TIME> TO <TIME_UNIT>)'\n"
       + "'" + kind + "(<TIMESTAMP> TO <TIME_UNIT>)'",
       OperandTypes.DATETIME,
       OperandTypes.ANY)),
   SqlFunctionCategory.NUMERIC);
 Preconditions.checkArgument(kind == SqlKind.FLOOR || kind == SqlKind.CEIL);
}
origin: apache/hive

private HiveFloorDate(String name) {
 super(name, SqlKind.FLOOR, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
   OperandTypes.sequence(
     "'" + SqlKind.FLOOR + "(<DATE> TO <TIME_UNIT>)'\n"
     + "'" + SqlKind.FLOOR + "(<TIME> TO <TIME_UNIT>)'\n"
     + "'" + SqlKind.FLOOR + "(<TIMESTAMP> TO <TIME_UNIT>)'",
     OperandTypes.DATETIME,
     OperandTypes.ANY),
   SqlFunctionCategory.NUMERIC);
}
origin: Qihoo360/Quicksql

public SqlRandIntegerFunction() {
 super("RAND_INTEGER",
   SqlKind.OTHER_FUNCTION,
   ReturnTypes.INTEGER,
   null,
   OperandTypes.or(OperandTypes.NUMERIC, OperandTypes.NUMERIC_NUMERIC),
   SqlFunctionCategory.NUMERIC);
}
origin: org.apache.calcite/calcite-core

public SqlUnnestOperator(boolean withOrdinality) {
 super(
   "UNNEST",
   SqlKind.UNNEST,
   200,
   true,
   null,
   null,
   OperandTypes.repeat(SqlOperandCountRanges.from(1),
     OperandTypes.SCALAR_OR_RECORD_COLLECTION_OR_MAP));
 this.withOrdinality = withOrdinality;
}
origin: org.apache.calcite/calcite-core

private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) {
 switch (operandType.getSqlTypeName()) {
 case ARRAY:
  return OperandTypes.family(SqlTypeFamily.INTEGER);
 case MAP:
  return OperandTypes.family(
    operandType.getKeyType().getSqlTypeName().getFamily());
 case ANY:
 case DYNAMIC_STAR:
  return OperandTypes.or(
    OperandTypes.family(SqlTypeFamily.INTEGER),
    OperandTypes.family(SqlTypeFamily.CHARACTER));
 default:
  throw new AssertionError(operandType.getSqlTypeName());
 }
}
origin: org.apache.calcite/calcite-core

public SqlFloorFunction(SqlKind kind) {
 super(kind.name(), kind, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
   OperandTypes.or(OperandTypes.NUMERIC_OR_INTERVAL,
     OperandTypes.sequence(
       "'" + kind + "(<DATE> TO <TIME_UNIT>)'\n"
       + "'" + kind + "(<TIME> TO <TIME_UNIT>)'\n"
       + "'" + kind + "(<TIMESTAMP> TO <TIME_UNIT>)'",
       OperandTypes.DATETIME,
       OperandTypes.ANY)),
   SqlFunctionCategory.NUMERIC);
 Preconditions.checkArgument(kind == SqlKind.FLOOR || kind == SqlKind.CEIL);
}
origin: apache/drill

private HiveFloorDate(String name) {
 super(name, SqlKind.FLOOR, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
   OperandTypes.sequence(
     "'" + SqlKind.FLOOR + "(<DATE> TO <TIME_UNIT>)'\n"
     + "'" + SqlKind.FLOOR + "(<TIME> TO <TIME_UNIT>)'\n"
     + "'" + SqlKind.FLOOR + "(<TIMESTAMP> TO <TIME_UNIT>)'",
     OperandTypes.DATETIME,
     OperandTypes.ANY),
   SqlFunctionCategory.NUMERIC);
}
origin: org.apache.calcite/calcite-core

public SqlRandIntegerFunction() {
 super("RAND_INTEGER",
   SqlKind.OTHER_FUNCTION,
   ReturnTypes.INTEGER,
   null,
   OperandTypes.or(OperandTypes.NUMERIC, OperandTypes.NUMERIC_NUMERIC),
   SqlFunctionCategory.NUMERIC);
}
origin: Qihoo360/Quicksql

public SqlUnnestOperator(boolean withOrdinality) {
 super(
   "UNNEST",
   SqlKind.UNNEST,
   200,
   true,
   null,
   null,
   OperandTypes.repeat(SqlOperandCountRanges.from(1),
     OperandTypes.SCALAR_OR_RECORD_COLLECTION_OR_MAP));
 this.withOrdinality = withOrdinality;
}
origin: apache/hive

private static CalciteUDFInfo getUDFInfo(String hiveUdfName,
  ImmutableList<RelDataType> calciteArgTypes, RelDataType calciteRetType) {
 CalciteUDFInfo udfInfo = new CalciteUDFInfo();
 udfInfo.udfName = hiveUdfName;
 udfInfo.returnTypeInference = ReturnTypes.explicit(calciteRetType);
 udfInfo.operandTypeInference = InferTypes.explicit(calciteArgTypes);
 ImmutableList.Builder<SqlTypeFamily> typeFamilyBuilder = new ImmutableList.Builder<SqlTypeFamily>();
 for (RelDataType at : calciteArgTypes) {
  typeFamilyBuilder.add(Util.first(at.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
 }
 udfInfo.operandTypeChecker = OperandTypes.family(typeFamilyBuilder.build());
 return udfInfo;
}
origin: io.druid.extensions/druid-histogram

 QuantileSqlAggFunction()
 {
  super(
    NAME,
    null,
    SqlKind.OTHER_FUNCTION,
    ReturnTypes.explicit(SqlTypeName.DOUBLE),
    null,
    OperandTypes.or(
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE1, OperandTypes.ANY, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC)
      ),
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE2, OperandTypes.ANY, OperandTypes.LITERAL, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC, SqlTypeFamily.EXACT_NUMERIC)
      )
    ),
    SqlFunctionCategory.NUMERIC,
    false,
    false
  );
 }
}
origin: org.apache.calcite/calcite-core

SqlOverlapsOperator(SqlKind kind) {
 super(kind.sql, kind, 30, true, ReturnTypes.BOOLEAN_NULLABLE,
   InferTypes.FIRST_KNOWN,
   OperandTypes.sequence("'<PERIOD> " + kind.sql + " <PERIOD>'",
     OperandTypes.PERIOD, OperandTypes.PERIOD));
}
origin: org.apache.calcite/calcite-core

public SqlJsonExistsFunction() {
 super("JSON_EXISTS", SqlKind.OTHER_FUNCTION,
   ReturnTypes.BOOLEAN_FORCE_NULLABLE, null,
   OperandTypes.or(OperandTypes.ANY, OperandTypes.ANY_ANY),
   SqlFunctionCategory.SYSTEM);
}
origin: apache/kylin

SqlAggFunction createCustomAggFunction(String funcName, RelDataType returnType, Class<?> customAggFuncClz) {
  RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
  SqlIdentifier sqlIdentifier = new SqlIdentifier(funcName, new SqlParserPos(1, 1));
  AggregateFunction aggFunction = AggregateFunctionImpl.create(customAggFuncClz);
  List<RelDataType> argTypes = new ArrayList<RelDataType>();
  List<SqlTypeFamily> typeFamilies = new ArrayList<SqlTypeFamily>();
  for (FunctionParameter o : aggFunction.getParameters()) {
    final RelDataType type = o.getType(typeFactory);
    argTypes.add(type);
    typeFamilies.add(Util.first(type.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
  }
  return new SqlUserDefinedAggFunction(sqlIdentifier, ReturnTypes.explicit(returnType),
      InferTypes.explicit(argTypes), OperandTypes.family(typeFamilies), aggFunction, false, false,
      typeFactory);
}
origin: org.apache.druid.extensions/druid-histogram

 QuantileSqlAggFunction()
 {
  super(
    NAME,
    null,
    SqlKind.OTHER_FUNCTION,
    ReturnTypes.explicit(SqlTypeName.DOUBLE),
    null,
    OperandTypes.or(
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE1, OperandTypes.ANY, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC)
      ),
      OperandTypes.and(
        OperandTypes.sequence(SIGNATURE2, OperandTypes.ANY, OperandTypes.LITERAL, OperandTypes.LITERAL),
        OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC, SqlTypeFamily.EXACT_NUMERIC)
      )
    ),
    SqlFunctionCategory.NUMERIC,
    false,
    false
  );
 }
}
origin: Qihoo360/Quicksql

SqlOverlapsOperator(SqlKind kind) {
 super(kind.sql, kind, 30, true, ReturnTypes.BOOLEAN_NULLABLE,
   InferTypes.FIRST_KNOWN,
   OperandTypes.sequence("'<PERIOD> " + kind.sql + " <PERIOD>'",
     OperandTypes.PERIOD, OperandTypes.PERIOD));
}
org.apache.calcite.sql.typeOperandTypes

Javadoc

Strategies for checking operand types.

This class defines singleton instances of strategy objects for operand type checking. org.apache.calcite.sql.type.ReturnTypesand org.apache.calcite.sql.type.InferTypes provide similar strategies for operand type inference and operator return type inference.

Note to developers: avoid anonymous inner classes here except for unique, non-generalizable strategies; anything else belongs in a reusable top-level class. If you find yourself copying and pasting an existing strategy's anonymous inner class, you're making a mistake.

Most used methods

  • family
    Creates a checker that passes if each operand is a member of a corresponding family.
  • sequence
    Creates an operand checker from a sequence of single-operand checkers.
  • or
    Creates a single-operand checker that passes if any one of the rules passes.
  • and
    Creates a single-operand checker that passes if all of the rules pass.
  • repeat
    Creates a checker that passes if all of the rules pass for each operand, using a given operand count

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JList (javax.swing)
  • Join (org.hibernate.mapping)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now