Java Code Examples for org.apache.calcite.sql.type.SqlTypeName#DEFAULT_INTERVAL_START_PRECISION

The following examples show how to use org.apache.calcite.sql.type.SqlTypeName#DEFAULT_INTERVAL_START_PRECISION . 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: RelDataTypeSystemImpl.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override public int getDefaultPrecision(SqlTypeName typeName) {
  // Following BasicSqlType precision as the default
  switch (typeName) {
  case CHAR:
  case BINARY:
    return 1;
  case VARCHAR:
  case VARBINARY:
    return RelDataType.PRECISION_NOT_SPECIFIED;
  case DECIMAL:
    return getMaxNumericPrecision();
  case INTERVAL_YEAR:
  case INTERVAL_YEAR_MONTH:
  case INTERVAL_MONTH:
  case INTERVAL_DAY:
  case INTERVAL_DAY_HOUR:
  case INTERVAL_DAY_MINUTE:
  case INTERVAL_DAY_SECOND:
  case INTERVAL_HOUR:
  case INTERVAL_HOUR_MINUTE:
  case INTERVAL_HOUR_SECOND:
  case INTERVAL_MINUTE:
  case INTERVAL_MINUTE_SECOND:
  case INTERVAL_SECOND:
    return SqlTypeName.DEFAULT_INTERVAL_START_PRECISION;
  case BOOLEAN:
    return 1;
  case TINYINT:
    return 3;
  case SMALLINT:
    return 5;
  case INTEGER:
    return 10;
  case BIGINT:
    return 19;
  case REAL:
    return 7;
  case FLOAT:
  case DOUBLE:
    return 15;
  case TIME:
  case TIME_WITH_LOCAL_TIME_ZONE:
  case DATE:
    return 0; // SQL99 part 2 section 6.1 syntax rule 30
  case TIMESTAMP:
  case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
    // farrago supports only 0 (see
    // SqlTypeName.getDefaultPrecision), but it should be 6
    // (microseconds) per SQL99 part 2 section 6.1 syntax rule 30.
    return 0;
  default:
    return -1;
  }
}
 
Example 2
Source File: RelDataTypeSystemImpl.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public int getDefaultPrecision(SqlTypeName typeName) {
  // Following BasicSqlType precision as the default
  switch (typeName) {
  case CHAR:
  case BINARY:
    return 1;
  case VARCHAR:
  case VARBINARY:
    return RelDataType.PRECISION_NOT_SPECIFIED;
  case DECIMAL:
    return getMaxNumericPrecision();
  case INTERVAL_YEAR:
  case INTERVAL_YEAR_MONTH:
  case INTERVAL_MONTH:
  case INTERVAL_DAY:
  case INTERVAL_DAY_HOUR:
  case INTERVAL_DAY_MINUTE:
  case INTERVAL_DAY_SECOND:
  case INTERVAL_HOUR:
  case INTERVAL_HOUR_MINUTE:
  case INTERVAL_HOUR_SECOND:
  case INTERVAL_MINUTE:
  case INTERVAL_MINUTE_SECOND:
  case INTERVAL_SECOND:
    return SqlTypeName.DEFAULT_INTERVAL_START_PRECISION;
  case BOOLEAN:
    return 1;
  case TINYINT:
    return 3;
  case SMALLINT:
    return 5;
  case INTEGER:
    return 10;
  case BIGINT:
    return 19;
  case REAL:
    return 7;
  case FLOAT:
  case DOUBLE:
    return 15;
  case TIME:
  case TIME_WITH_LOCAL_TIME_ZONE:
  case DATE:
    return 0; // SQL99 part 2 section 6.1 syntax rule 30
  case TIMESTAMP:
  case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
    // farrago supports only 0 (see
    // SqlTypeName.getDefaultPrecision), but it should be 6
    // (microseconds) per SQL99 part 2 section 6.1 syntax rule 30.
    return 0;
  default:
    return -1;
  }
}