Java Code Examples for org.apache.calcite.sql.SqlFunctionCategory#STRING

The following examples show how to use org.apache.calcite.sql.SqlFunctionCategory#STRING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlFloorFunction.java    From Bats with Apache License 2.0 6 votes vote down vote up
/**
 * Most dialects that natively support datetime floor will use this.
 * In those cases the call will look like TRUNC(datetime, 'year').
 *
 * @param writer SqlWriter
 * @param call SqlCall
 * @param funName Name of the sql function to call
 * @param datetimeFirst Specify the order of the datetime & timeUnit
 * arguments
 */
public static void unparseDatetimeFunction(SqlWriter writer, SqlCall call,
    String funName, Boolean datetimeFirst) {
  SqlFunction func = new SqlFunction(funName, SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
      SqlFunctionCategory.STRING);

  SqlCall call1;
  if (datetimeFirst) {
    call1 = call;
  } else {
    // switch order of operands
    SqlNode op1 = call.operand(0);
    SqlNode op2 = call.operand(1);

    call1 = call.getOperator().createCall(call.getParserPosition(), op2, op1);
  }

  SqlUtil.unparseFunctionSyntax(func, writer, call1);
}
 
Example 2
Source File: SqlFloorFunction.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Most dialects that natively support datetime floor will use this.
 * In those cases the call will look like TRUNC(datetime, 'year').
 *
 * @param writer SqlWriter
 * @param call SqlCall
 * @param funName Name of the sql function to call
 * @param datetimeFirst Specify the order of the datetime & timeUnit
 * arguments
 */
public static void unparseDatetimeFunction(SqlWriter writer, SqlCall call,
    String funName, Boolean datetimeFirst) {
  SqlFunction func = new SqlFunction(funName, SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
      SqlFunctionCategory.STRING);

  SqlCall call1;
  if (datetimeFirst) {
    call1 = call;
  } else {
    // switch order of operands
    SqlNode op1 = call.operand(0);
    SqlNode op2 = call.operand(1);

    call1 = call.getOperator().createCall(call.getParserPosition(), op2, op1);
  }

  SqlUtil.unparseFunctionSyntax(func, writer, call1);
}
 
Example 3
Source File: SqlSubstringFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the SqlSubstringFunction.
 */
SqlSubstringFunction() {
  super(
      "SUBSTRING",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING,
      null,
      null,
      SqlFunctionCategory.STRING);
}
 
Example 4
Source File: SqlTranslate3Function.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the SqlTranslate3Function.
 */
SqlTranslate3Function() {
  super("TRANSLATE3",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING,
      null,
      OperandTypes.STRING_STRING_STRING,
      SqlFunctionCategory.STRING);
}
 
Example 5
Source File: SqlOverlayFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlOverlayFunction() {
  super(
      "OVERLAY",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.DYADIC_STRING_SUM_PRECISION_NULLABLE_VARYING,
      null,
      OTC_CUSTOM,
      SqlFunctionCategory.STRING);
}
 
Example 6
Source File: SqlConvertFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
protected SqlConvertFunction(String name) {
  super(
      name,
      SqlKind.OTHER_FUNCTION,
      null,
      null,
      null,
      SqlFunctionCategory.STRING);
}
 
Example 7
Source File: SqlSubstringFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the SqlSubstringFunction.
 */
SqlSubstringFunction() {
  super(
      "SUBSTRING",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING,
      null,
      null,
      SqlFunctionCategory.STRING);
}
 
Example 8
Source File: SqlRegexpReplaceFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlRegexpReplaceFunction() {
  super("REGEXP_REPLACE",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.cascade(ReturnTypes.explicit(SqlTypeName.VARCHAR),
          SqlTypeTransforms.TO_NULLABLE),
      null,
      null,
      SqlFunctionCategory.STRING);
}
 
Example 9
Source File: SqlTranslate3Function.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the SqlTranslate3Function.
 */
SqlTranslate3Function() {
  super("TRANSLATE3",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.ARG0_NULLABLE_VARYING,
      null,
      OperandTypes.STRING_STRING_STRING,
      SqlFunctionCategory.STRING);
}
 
Example 10
Source File: SqlOverlayFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlOverlayFunction() {
  super(
      "OVERLAY",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.DYADIC_STRING_SUM_PRECISION_NULLABLE_VARYING,
      null,
      OTC_CUSTOM,
      SqlFunctionCategory.STRING);
}
 
Example 11
Source File: SqlConvertFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
protected SqlConvertFunction(String name) {
  super(
      name,
      SqlKind.OTHER_FUNCTION,
      null,
      null,
      null,
      SqlFunctionCategory.STRING);
}
 
Example 12
Source File: SqlTrimFunction.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlTrimFunction(String name, SqlKind kind,
    SqlTypeTransformCascade returnTypeInference,
    SqlSingleOperandTypeChecker operandTypeChecker) {
  super(name, kind, returnTypeInference, null, operandTypeChecker,
      SqlFunctionCategory.STRING);
}
 
Example 13
Source File: SqlTrimFunction.java    From calcite with Apache License 2.0 4 votes vote down vote up
public SqlTrimFunction(String name, SqlKind kind,
    SqlTypeTransformCascade returnTypeInference,
    SqlSingleOperandTypeChecker operandTypeChecker) {
  super(name, kind, returnTypeInference, null, operandTypeChecker,
      SqlFunctionCategory.STRING);
}