Java Code Examples for org.apache.calcite.rel.type.RelDataType#getIntervalQualifier()

The following examples show how to use org.apache.calcite.rel.type.RelDataType#getIntervalQualifier() . 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: View.java    From Bats with Apache License 2.0 5 votes vote down vote up
public Field(String name, RelDataType dataType) {
  this.name = name;
  this.type = dataType.getSqlTypeName();
  this.isNullable = dataType.isNullable();
  this.intervalQualifier = dataType.getIntervalQualifier();
  switch (dataType.getSqlTypeName()) {
    case CHAR:
    case BINARY:
    case VARBINARY:
    case VARCHAR:
      this.precision = dataType.getPrecision();
      break;
    case DECIMAL:
      this.precision = dataType.getPrecision();
      this.scale = dataType.getScale();
      break;
    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:
      this.precision = dataType.getIntervalQualifier().getStartPrecisionPreservingDefault();
      break;
    case MAP:
      keyType = new Field(dataType.getKeyType());
      valueType = new Field(dataType.getValueType());
      break;
  }
}
 
Example 2
Source File: SqlTypeFactoryImpl.java    From Bats with Apache License 2.0 4 votes vote down vote up
private RelDataType copyIntervalType(RelDataType type, boolean nullable) {
  return new IntervalSqlType(typeSystem,
      type.getIntervalQualifier(),
      nullable);
}
 
Example 3
Source File: View.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public FieldType(String name, RelDataType dataType) {
  this.name = name;
  this.type = dataType.getSqlTypeName();

  Integer p = null;
  Integer s = null;

  switch (dataType.getSqlTypeName()) {
  case CHAR:
  case BINARY:
  case VARBINARY:
  case VARCHAR:
    p = dataType.getPrecision();
    break;
  case DECIMAL:
    p = dataType.getPrecision();
    s = dataType.getScale();
    break;
  case TIME:
  case TIMESTAMP:
    p = dataType.getPrecision();
    break;
  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:
    p = dataType.getIntervalQualifier().getStartPrecisionPreservingDefault();
  default:
    break;
  }

  this.precision = p;
  this.scale = s;
  this.intervalQualifier = dataType.getIntervalQualifier();
  this.isNullable = dataType.isNullable();
}
 
Example 4
Source File: SqlTypeFactoryImpl.java    From calcite with Apache License 2.0 4 votes vote down vote up
private RelDataType copyIntervalType(RelDataType type, boolean nullable) {
  return new IntervalSqlType(typeSystem,
      type.getIntervalQualifier(),
      nullable);
}