|
39 | 39 | import tech.ydb.table.description.TableIndex; |
40 | 40 | import tech.ydb.table.result.ResultSetReader; |
41 | 41 | import tech.ydb.table.settings.DescribeTableSettings; |
| 42 | +import tech.ydb.table.values.DecimalType; |
42 | 43 | import tech.ydb.table.values.PrimitiveType; |
43 | 44 | import tech.ydb.table.values.Type; |
44 | 45 |
|
@@ -799,7 +800,14 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa |
799 | 800 | nullable = columnNoNulls; |
800 | 801 | } |
801 | 802 |
|
802 | | - int decimalDigits = type.getKind() == Type.Kind.DECIMAL ? YdbConst.SQL_DECIMAL_DEFAULT_PRECISION : 0; |
| 803 | + int decimalDigits = 0; |
| 804 | + if (type.getKind() == Type.Kind.DECIMAL) { |
| 805 | + if (type instanceof DecimalType) { |
| 806 | + decimalDigits = ((DecimalType) type).getPrecision(); |
| 807 | + } else { |
| 808 | + decimalDigits = DecimalType.getDefault().getPrecision(); |
| 809 | + } |
| 810 | + } |
803 | 811 |
|
804 | 812 | rs.newRow() |
805 | 813 | .withTextValue("TABLE_NAME", tableName) |
@@ -874,11 +882,17 @@ public ResultSet getBestRowIdentifier(String catalog, String schema, String tabl |
874 | 882 | for (String key : description.getPrimaryKeys()) { |
875 | 883 | TableColumn column = columnMap.get(key); |
876 | 884 | Type type = column.getType(); |
| 885 | + int decimalDigits = 0; |
877 | 886 | if (type.getKind() == Type.Kind.OPTIONAL) { |
878 | 887 | type = type.unwrapOptional(); |
879 | 888 | } |
880 | | - |
881 | | - int decimalDigits = type.getKind() == Type.Kind.DECIMAL ? YdbConst.SQL_DECIMAL_DEFAULT_PRECISION : 0; |
| 889 | + if (type.getKind() == Type.Kind.DECIMAL) { |
| 890 | + if (type instanceof DecimalType) { |
| 891 | + decimalDigits = ((DecimalType) type).getPrecision(); |
| 892 | + } else { |
| 893 | + decimalDigits = DecimalType.getDefault().getPrecision(); |
| 894 | + } |
| 895 | + } |
882 | 896 |
|
883 | 897 | rs.newRow() |
884 | 898 | .withShortValue("SCOPE", (short) scope) |
@@ -962,7 +976,15 @@ public ResultSet getTypeInfo() { |
962 | 976 |
|
963 | 977 | for (Type type: YdbTypes.getAllDatabaseTypes()) { |
964 | 978 | String literal = getLiteral(type); |
965 | | - int scale = type.getKind() == Type.Kind.DECIMAL ? YdbConst.SQL_DECIMAL_DEFAULT_SCALE : 0; |
| 979 | + int scale = 0; |
| 980 | + if (type.getKind() == Type.Kind.DECIMAL) { |
| 981 | + if (type instanceof DecimalType) { |
| 982 | + scale = ((DecimalType) type).getScale(); |
| 983 | + } else { |
| 984 | + scale = DecimalType.getDefault().getScale(); |
| 985 | + } |
| 986 | + } |
| 987 | + |
966 | 988 | rs.newRow() |
967 | 989 | .withTextValue("TYPE_NAME", type.toString()) |
968 | 990 | .withIntValue("DATA_TYPE", YdbTypes.toSqlType(type)) |
|
0 commit comments