Java Code Examples for org.apache.calcite.sql.SqlDataTypeSpec#getPrecision()
The following examples show how to use
org.apache.calcite.sql.SqlDataTypeSpec#getPrecision() .
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: ExpressionComparator.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
protected boolean isSqlDataTypeSpecEqual(SqlDataTypeSpec querySqlDataTypeSpec, SqlDataTypeSpec exprSqlDataTypeSpec) { if (querySqlDataTypeSpec.getTypeName() == null || CollectionUtils.isEmpty(querySqlDataTypeSpec.getTypeName().names)) return false; if (querySqlDataTypeSpec.getTypeName().names.size() != exprSqlDataTypeSpec.getTypeName().names.size()) return false; for (int i = 0; i < querySqlDataTypeSpec.getTypeName().names.size(); i++) { String queryName = querySqlDataTypeSpec.getTypeName().names.get(i); if (!exprSqlDataTypeSpec.getTypeName().names.contains(queryName)) { return false; } } return querySqlDataTypeSpec.getScale() == exprSqlDataTypeSpec.getScale() && querySqlDataTypeSpec.getPrecision() == exprSqlDataTypeSpec.getPrecision(); }
Example 2
Source File: ConvSqlWriter.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public void userDefinedType(SqlDataTypeSpec typeSpec, int leftPrec, int rightPrec) { keyword(typeSpec.getTypeName().getSimple()); // also print precision and scale for user-defined-type int precision = typeSpec.getPrecision(); int scale = typeSpec.getScale(); if (precision >= 0) { final SqlWriter.Frame frame = startList(SqlWriter.FrameTypeEnum.FUN_CALL, "(", ")"); this.print(precision); if (scale >= 0) { this.sep(",", true); this.print(scale); } this.endList(frame); } }
Example 3
Source File: ConvMaster.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
SqlDataTypeSpec findTargetSqlDataTypeSpec(SqlDataTypeSpec typeSpec) { if (sourceDS == null || targetDS == null || typeSpec == null) return null; List<TypeDef> validTypeDefs = sourceDS.getTypeDefsByName(typeSpec.getTypeName().toString()); if (validTypeDefs != null) { for (TypeDef typeDef : validTypeDefs) { if (typeDef.getMaxPrecision() >= typeSpec.getPrecision()) { TypeDef targetType = targetDS.getTypeDef(typeDef.getId()); return new SqlDataTypeSpec(new SqlIdentifier(targetType.getName(), typeSpec.getParserPosition()), targetType.getDefaultPrecision() >= 0 ? targetType.getDefaultPrecision() : typeSpec.getPrecision(), targetType.getDefaultScale() >= 0 ? targetType.getDefaultScale() : typeSpec.getScale(), typeSpec.getCharSetName(), typeSpec.getTimeZone(), typeSpec.getParserPosition()); } } } return null; }
Example 4
Source File: ExpressionComparator.java From kylin with Apache License 2.0 | 6 votes |
protected boolean isSqlDataTypeSpecEqual(SqlDataTypeSpec querySqlDataTypeSpec, SqlDataTypeSpec exprSqlDataTypeSpec) { if (querySqlDataTypeSpec.getTypeName() == null || CollectionUtils.isEmpty(querySqlDataTypeSpec.getTypeName().names)) return false; if (querySqlDataTypeSpec.getTypeName().names.size() != exprSqlDataTypeSpec.getTypeName().names.size()) return false; for (int i = 0; i < querySqlDataTypeSpec.getTypeName().names.size(); i++) { String queryName = querySqlDataTypeSpec.getTypeName().names.get(i); if (!exprSqlDataTypeSpec.getTypeName().names.contains(queryName)) { return false; } } return querySqlDataTypeSpec.getScale() == exprSqlDataTypeSpec.getScale() && querySqlDataTypeSpec.getPrecision() == exprSqlDataTypeSpec.getPrecision(); }
Example 5
Source File: ConvSqlWriter.java From kylin with Apache License 2.0 | 6 votes |
@Override public void userDefinedType(SqlDataTypeSpec typeSpec, int leftPrec, int rightPrec) { keyword(typeSpec.getTypeName().getSimple()); // also print precision and scale for user-defined-type int precision = typeSpec.getPrecision(); int scale = typeSpec.getScale(); if (precision >= 0) { final SqlWriter.Frame frame = startList(SqlWriter.FrameTypeEnum.FUN_CALL, "(", ")"); this.print(precision); if (scale >= 0) { this.sep(",", true); this.print(scale); } this.endList(frame); } }
Example 6
Source File: ConvMaster.java From kylin with Apache License 2.0 | 6 votes |
SqlDataTypeSpec findTargetSqlDataTypeSpec(SqlDataTypeSpec typeSpec) { if (sourceDS == null || targetDS == null || typeSpec == null) return null; List<TypeDef> validTypeDefs = sourceDS.getTypeDefsByName(typeSpec.getTypeName().toString()); if (validTypeDefs != null) { for (TypeDef typeDef : validTypeDefs) { if (typeDef.getMaxPrecision() >= typeSpec.getPrecision()) { TypeDef targetType = targetDS.getTypeDef(typeDef.getId()); return new SqlDataTypeSpec(new SqlIdentifier(targetType.getName(), typeSpec.getParserPosition()), targetType.getDefaultPrecision() >= 0 ? targetType.getDefaultPrecision() : typeSpec.getPrecision(), targetType.getDefaultScale() >= 0 ? targetType.getDefaultScale() : typeSpec.getScale(), typeSpec.getCharSetName(), typeSpec.getTimeZone(), typeSpec.getParserPosition()); } } } return null; }