hi, mbudiu.

I get your point.  Ofcourse, we can override `RelDataTypeSystemImpl`.
however, my suggestion is that we change the maximum 19 of
`RelDataTypeSystemImpl` to meet the mature engines,
If there is no specific reason for setting the maximum value of 19.

<mbu...@gmail.com> 于2023年8月8日周二 01:03写道:

> Calcite gives you hooks to change these limits.
>
> For example:
>
> public static final RelDataTypeSystem TYPE_SYSTEM = new
> RelDataTypeSystemImpl() {
>         @Override
>         public int getMaxNumericPrecision() {
>             return MAX_PRECISION;
>         }
>         @Override
>         public int getMaxNumericScale() {
>             return MAX_SCALE;
>         }
>         @Override
>         public boolean shouldConvertRaggedUnionTypesToVarying() { return
> true; }
>     };
>
>
> this.typeFactory = new SqlTypeFactoryImpl(TYPE_SYSTEM);
>
> Then you can use this type factory in other structures you build, like the
> CatalogReader, the Validator, and the Cluster.
>
>
> -----Original Message-----
> From: Ran Tao
> Sent: Sunday, August 06, 2023 7:58 PM
> To: dev@calcite.apache.org
> Subject: [DISCUSS] Increase the default maximum precision and scale of the
> number type
>
> Hi, devs. I have noticed that currently calcite default maximum precision
> and scale is 19.
> If we set Decimal(50,2), it will reduce to Decimal(19,2).
> while other mature database systems or bigdata engines have more bigger
> value.
>
> For consistency and to give calcite users a standard value that meets most
> engines, can we adjust the value of calcite to 38?
>
> Besides, the sql standard defines the meaning of precision and scale,
> letting each system customize the maximum precision and scale. (sql1999,
> page 125)
>
> engine precision range scale range
> calcite [1,19] [1,19]
> oracle [1,38] [-84,127]
> sqlserver [1,38] [0,38]
> mysql [1,65] [0,30]
> spark [1,38] [0,38]
> hive [1,38] [0,38]
> flink [1,38] [0,38]
> We can see many systems or engines follow the sql standard to make maximum
> precision and scale to be 38, except oracle and mysql.
>
> If anyone can share some history or reasons why calcite set 19, i will
> appreciate it.
>
> [1]
>
> https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlqr/Data-Types.html#GUID-DCCC6F18-15A0-4ECC-BA48-16F73F844844
>
> [2]
>
> https://learn.microsoft.com/en-us/sql/t-sql/data-types/decimal-and-numeric-transact-sql?view=sql-server-ver15
>
> [3]
>
> https://dev.mysql.com/doc/refman/8.0/en/precision-math-decimal-characteristics.html
>
> [4]
>
> https://spark.apache.org/docs/3.2.0/api/java/org/apache/spark/sql/types/DecimalType.html
>
> [5]
>
> https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=82706456#LanguageManualTypes-decimal
>
> [6]
>
> https://nightlies.apache.org/flink/flink-docs-master/api/java/org/apache/flink/table/api/DataTypes.html
>
>
> Best Regards,
> Ran Tao
> https://github.com/chucheng92
>
>

Reply via email to