congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SqlTypeUtil.convertTypeToSpec
Code IndexAdd Tabnine to your IDE (free)

How to use
convertTypeToSpec
method
in
org.apache.calcite.sql.type.SqlTypeUtil

Best Java code snippets using org.apache.calcite.sql.type.SqlTypeUtil.convertTypeToSpec (Showing top 14 results out of 315)

origin: apache/flink

private SqlNode maybeCast(SqlNode node, RelDataType currentType,
  RelDataType desiredType) {
  return currentType.equals(desiredType)
    || (currentType.isNullable() != desiredType.isNullable()
        && typeFactory.createTypeWithNullability(currentType,
    desiredType.isNullable()).equals(desiredType))
    ? node
    : SqlStdOperatorTable.CAST.createCall(SqlParserPos.ZERO,
    node, SqlTypeUtil.convertTypeToSpec(desiredType));
}
origin: Qihoo360/Quicksql

 private SqlNode getCastedSqlNode(SqlNode argInput, RelDataType varType,
   SqlParserPos pos, RexNode argRex) {
  SqlNode arg;
  if (argRex != null && !argRex.getType().equals(varType)) {
   arg = SqlStdOperatorTable.CAST.createCall(
     pos, argInput, SqlTypeUtil.convertTypeToSpec(varType));
  } else {
   arg = argInput;
  }
  return arg;
 }
}
origin: org.apache.calcite/calcite-core

 private SqlNode getCastedSqlNode(SqlNode argInput, RelDataType varType,
   SqlParserPos pos, RexNode argRex) {
  SqlNode arg;
  if (argRex != null && !argRex.getType().equals(varType)) {
   arg = SqlStdOperatorTable.CAST.createCall(
     pos, argInput, SqlTypeUtil.convertTypeToSpec(varType));
  } else {
   arg = argInput;
  }
  return arg;
 }
}
origin: org.apache.calcite/calcite-core

 private SqlNode getCastedSqlNode(SqlNode argInput, RelDataType varType,
   SqlParserPos pos, RexNode argRex) {
  SqlNode arg;
  if (argRex != null && !argRex.getType().equals(varType)) {
   arg = SqlStdOperatorTable.CAST.createCall(
     pos, argInput, SqlTypeUtil.convertTypeToSpec(varType));
  } else {
   arg = argInput;
  }
  return arg;
 }
}
origin: Qihoo360/Quicksql

 private SqlNode getCastedSqlNode(SqlNode argInput, RelDataType varType,
   SqlParserPos pos, RexNode argRex) {
  SqlNode arg;
  if (argRex != null && !argRex.getType().equals(varType)) {
   arg = SqlStdOperatorTable.CAST.createCall(
     pos, argInput, SqlTypeUtil.convertTypeToSpec(varType));
  } else {
   arg = argInput;
  }
  return arg;
 }
}
origin: org.apache.calcite/calcite-core

/**
 * Creates and registers a convertlet for an operator in which
 * the SQL representation needs the result type appended
 * as an extra argument (e.g. CAST).
 *
 * @param op operator instance
 */
private void registerTypeAppendOp(final SqlOperator op) {
 registerOp(
   op, (converter, call) -> {
    SqlNode[] operands =
      convertExpressionList(converter, call.operands);
    if (operands == null) {
     return null;
    }
    List<SqlNode> operandList =
      new ArrayList<>(Arrays.asList(operands));
    SqlDataTypeSpec typeSpec =
      SqlTypeUtil.convertTypeToSpec(call.getType());
    operandList.add(typeSpec);
    return new SqlBasicCall(
      op,
      operandList.toArray(new SqlNode[0]),
      SqlParserPos.ZERO);
   });
}
origin: Qihoo360/Quicksql

private SqlNode maybeCast(SqlNode node, RelDataType currentType,
  RelDataType desiredType) {
 return currentType.equals(desiredType)
   || (currentType.isNullable() != desiredType.isNullable()
     && typeFactory.createTypeWithNullability(currentType,
       desiredType.isNullable()).equals(desiredType))
   ? node
   : SqlStdOperatorTable.CAST.createCall(SqlParserPos.ZERO,
     node, SqlTypeUtil.convertTypeToSpec(desiredType));
}
origin: org.apache.calcite/calcite-core

private SqlNode maybeCast(SqlNode node, RelDataType currentType,
  RelDataType desiredType) {
 return currentType.equals(desiredType)
   || (currentType.isNullable() != desiredType.isNullable()
     && typeFactory.createTypeWithNullability(currentType,
       desiredType.isNullable()).equals(desiredType))
   ? node
   : SqlStdOperatorTable.CAST.createCall(SqlParserPos.ZERO,
     node, SqlTypeUtil.convertTypeToSpec(desiredType));
}
origin: Qihoo360/Quicksql

/**
 * Creates and registers a convertlet for an operator in which
 * the SQL representation needs the result type appended
 * as an extra argument (e.g. CAST).
 *
 * @param op operator instance
 */
private void registerTypeAppendOp(final SqlOperator op) {
 registerOp(
   op, (converter, call) -> {
    SqlNode[] operands =
      convertExpressionList(converter, call.operands);
    if (operands == null) {
     return null;
    }
    List<SqlNode> operandList =
      new ArrayList<>(Arrays.asList(operands));
    SqlDataTypeSpec typeSpec =
      SqlTypeUtil.convertTypeToSpec(call.getType());
    operandList.add(typeSpec);
    return new SqlBasicCall(
      op,
      operandList.toArray(new SqlNode[0]),
      SqlParserPos.ZERO);
   });
}
origin: Qihoo360/Quicksql

public SqlNode getCastSpec(RelDataType type) {
 if (type instanceof BasicSqlType) {
  return new SqlDataTypeSpec(
    new SqlIdentifier(type.getSqlTypeName().name(), SqlParserPos.ZERO),
      type.getPrecision(),
      type.getScale(),
      type.getCharset() != null
        && supportsCharSet()
        ? type.getCharset().name()
        : null,
      null,
      SqlParserPos.ZERO);
 }
 return SqlTypeUtil.convertTypeToSpec(type);
}
origin: Qihoo360/Quicksql

@Before
public void setUp() {
 JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
 integerDataType = typeFactory.createSqlType(SqlTypeName.INTEGER);
 integerType = SqlTypeUtil.convertTypeToSpec(integerDataType);
 rexBuilder = new RexBuilder(typeFactory);
}
origin: org.apache.calcite/calcite-core

@Before
public void setUp() {
 JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
 integerDataType = typeFactory.createSqlType(SqlTypeName.INTEGER);
 integerType = SqlTypeUtil.convertTypeToSpec(integerDataType);
 rexBuilder = new RexBuilder(typeFactory);
}
origin: org.apache.calcite/calcite-core

public SqlNode getCastSpec(RelDataType type) {
 if (type instanceof BasicSqlType) {
  int precision = type.getPrecision();
  switch (type.getSqlTypeName()) {
  case VARCHAR:
   // if needed, adjust varchar length to max length supported by the system
   int maxPrecision = getTypeSystem().getMaxPrecision(type.getSqlTypeName());
   if (type.getPrecision() > maxPrecision) {
    precision = maxPrecision;
   }
  }
  return new SqlDataTypeSpec(
    new SqlIdentifier(type.getSqlTypeName().name(), SqlParserPos.ZERO),
      precision,
      type.getScale(),
      type.getCharset() != null
        && supportsCharSet()
        ? type.getCharset().name()
        : null,
      null,
      SqlParserPos.ZERO);
 }
 return SqlTypeUtil.convertTypeToSpec(type);
}
origin: qubole/quark

private SqlNode toSql(RelDataType type) {
 switch (dialect.getDatabaseProduct()) {
  case MYSQL:
   switch (type.getSqlTypeName()) {
    case VARCHAR:
     // MySQL doesn't have a VARCHAR type, only CHAR.
     return new SqlDataTypeSpec(new SqlIdentifier("CHAR", POS),
       type.getPrecision(), -1, null, null, POS);
    case INTEGER:
     return new SqlDataTypeSpec(new SqlIdentifier("_UNSIGNED", POS),
       type.getPrecision(), -1, null, null, POS);
   }
   break;
 }
 if (type instanceof BasicSqlType) {
  return new SqlDataTypeSpec(
    new SqlIdentifier(type.getSqlTypeName().name(), POS),
    type.getPrecision(),
    type.getScale(),
    type.getCharset() != null
      && dialect.supportsCharSet()
      ? type.getCharset().name()
      : null,
    null,
    POS);
 }
 return SqlTypeUtil.convertTypeToSpec(type);
 //throw new AssertionError(type); // TODO: implement
}
org.apache.calcite.sql.typeSqlTypeUtilconvertTypeToSpec

Javadoc

Converts an instance of RelDataType to an instance of SqlDataTypeSpec.

Popular methods of SqlTypeUtil

  • canAssignFrom
    Tests whether a value can be assigned to a site.
  • equalSansNullability
    Returns whether two types are equal, ignoring nullability.They need not come from the same factory.
  • inBooleanFamily
  • isExactNumeric
  • isInterval
  • addCharsetAndCollation
    Adds collation and charset to a character type, returns other types unchanged.
  • areCharacterSetsMismatched
    Determines whether two types both have different character sets. If one or the other type has no cha
  • areSameFamily
    Returns whether all types in a collection have the same family, as determined by #isSameFamily(RelDa
  • comparePrecision
    Returns whether a precision is greater or equal than another, treating RelDataType#PRECISION_NOT_SPE
  • hasScale
    Returns whether a type's scale is set.
  • inCharFamily
  • isApproximateNumeric
  • inCharFamily,
  • isApproximateNumeric,
  • isComparable,
  • maxPrecision,
  • promoteToRowType,
  • canCastFrom,
  • canConvertStringInCompare,
  • containsNullable,
  • deriveAndCollectTypes

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Best plugins for Eclipse
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