ygerzhedovich commented on code in PR #5119:
URL: https://github.com/apache/ignite-3/pull/5119#discussion_r1942703218
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
+ */
+ public static int getMinPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MIN_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MIN_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MIN_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
Review Comment:
```suggestion
* Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
+ */
+ public static int getMinPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MIN_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MIN_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MIN_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Maximum length
+ */
+ public static int getMaxLength(ColumnType columnType) {
+ if (!columnType.lengthAllowed()) {
+ return UNSPECIFIED_LENGTH;
+ } else {
+ switch (columnType) {
+ case STRING:
+ case BYTE_ARRAY:
+ return MAX_VARLEN_LENGTH;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Minimum length
Review Comment:
```suggestion
* @param columnType Column type.
* @return Minimum length.
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/IgniteResource.java:
##########
@@ -85,8 +85,14 @@ public interface IgniteResource {
@BaseMessage("{0} datatype is not supported'")
ExInst<SqlValidatorException> dataTypeIsNotSupported(String a0);
- @BaseMessage("Length for type {0} must be at least 1")
- ExInst<SqlValidatorException> invalidStringLength(String typeName);
+ @BaseMessage("{0} length {1,number,#} must be between {2,number,#} and
{3,number,#}")
+ ExInst<SqlValidatorException> invalidLengthForType(String typeName, int
value, int min, int max);
+
+ @BaseMessage("{0} precision {1,number,#} must be between {2,number,#} and
{3,number,#}")
+ ExInst<SqlValidatorException> invalidPrecisionForType(String typeName, int
value, int min, int max);
+
+ @BaseMessage("{0} scale {1,number,#} must be between {2,number,#} and
{3,number,#}")
Review Comment:
```suggestion
@BaseMessage("{0} scale {1,number,#} must be between {2,number,#} and
{3,number,#}.")
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/IgniteResource.java:
##########
@@ -85,8 +85,14 @@ public interface IgniteResource {
@BaseMessage("{0} datatype is not supported'")
ExInst<SqlValidatorException> dataTypeIsNotSupported(String a0);
- @BaseMessage("Length for type {0} must be at least 1")
- ExInst<SqlValidatorException> invalidStringLength(String typeName);
+ @BaseMessage("{0} length {1,number,#} must be between {2,number,#} and
{3,number,#}")
+ ExInst<SqlValidatorException> invalidLengthForType(String typeName, int
value, int min, int max);
+
+ @BaseMessage("{0} precision {1,number,#} must be between {2,number,#} and
{3,number,#}")
Review Comment:
```suggestion
@BaseMessage("{0} precision {1,number,#} must be between {2,number,#}
and {3,number,#}.")
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
+ */
+ public static int getMinPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MIN_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MIN_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MIN_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Maximum length
Review Comment:
```suggestion
* @param columnType Column type.
* @return Maximum length.
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
Review Comment:
```suggestion
* @param columnType Column type.
* @return Minimum precision.
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/IgniteResource.java:
##########
@@ -85,8 +85,14 @@ public interface IgniteResource {
@BaseMessage("{0} datatype is not supported'")
ExInst<SqlValidatorException> dataTypeIsNotSupported(String a0);
- @BaseMessage("Length for type {0} must be at least 1")
- ExInst<SqlValidatorException> invalidStringLength(String typeName);
+ @BaseMessage("{0} length {1,number,#} must be between {2,number,#} and
{3,number,#}")
Review Comment:
```suggestion
@BaseMessage("{0} length {1,number,#} must be between {2,number,#} and
{3,number,#}.")
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
+ */
+ public static int getMinPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MIN_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MIN_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MIN_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Maximum length
+ */
+ public static int getMaxLength(ColumnType columnType) {
+ if (!columnType.lengthAllowed()) {
+ return UNSPECIFIED_LENGTH;
+ } else {
+ switch (columnType) {
+ case STRING:
+ case BYTE_ARRAY:
+ return MAX_VARLEN_LENGTH;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Minimum length
+ */
+ public static int getMinLength(ColumnType columnType) {
+ if (!columnType.lengthAllowed()) {
+ return UNSPECIFIED_LENGTH;
+ } else {
+ switch (columnType) {
+ case STRING:
+ case BYTE_ARRAY:
+ return MIN_VARLEN_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported scale for given type or {@link
#UNSPECIFIED_SCALE} if the type does not support scale.
+ *
+ * @param columnType Column type
+ * @return Maximum scale
Review Comment:
```suggestion
* @param columnType Column type.
* @return Maximum scale.
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
Review Comment:
```suggestion
* Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
```
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/CatalogUtils.java:
##########
@@ -547,6 +597,133 @@ public static HybridTimestamp
clusterWideEnsuredActivationTimestamp(long activat
return defaultZone != null ? defaultZone.id() : null;
}
+
+ /**
+ * Returns the maximum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Maximum precision
+ */
+ public static int getMaxPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MAX_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MAX_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MAX_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported precision for given type or {@link
#UNSPECIFIED_PRECISION} if the type does not support precision.
+ *
+ * @param columnType Column type
+ * @return Minimum precision
+ */
+ public static int getMinPrecision(ColumnType columnType) {
+ if (!columnType.precisionAllowed()) {
+ return UNSPECIFIED_PRECISION;
+ } else {
+ switch (columnType) {
+ case DECIMAL:
+ return MIN_DECIMAL_PRECISION;
+ case TIME:
+ case DATETIME:
+ case TIMESTAMP:
+ return MIN_TIME_PRECISION;
+ case DURATION:
+ case PERIOD:
+ return MIN_INTERVAL_TYPE_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Maximum length
+ */
+ public static int getMaxLength(ColumnType columnType) {
+ if (!columnType.lengthAllowed()) {
+ return UNSPECIFIED_LENGTH;
+ } else {
+ switch (columnType) {
+ case STRING:
+ case BYTE_ARRAY:
+ return MAX_VARLEN_LENGTH;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum supported length for given type or {@link
#UNSPECIFIED_LENGTH} if the type does not support length.
+ *
+ * @param columnType Column type
+ * @return Minimum length
+ */
+ public static int getMinLength(ColumnType columnType) {
+ if (!columnType.lengthAllowed()) {
+ return UNSPECIFIED_LENGTH;
+ } else {
+ switch (columnType) {
+ case STRING:
+ case BYTE_ARRAY:
+ return MIN_VARLEN_PRECISION;
+ default:
+ throw new IllegalArgumentException("Unexpected column
type: " + columnType);
+ }
+ }
+ }
+
+ /**
+ * Returns the maximum supported scale for given type or {@link
#UNSPECIFIED_SCALE} if the type does not support scale.
+ *
+ * @param columnType Column type
+ * @return Maximum scale
+ */
+ public static int getMaxScale(ColumnType columnType) {
+ if (!columnType.scaleAllowed()) {
+ return UNSPECIFIED_SCALE;
+ } else {
+ if (columnType == ColumnType.DECIMAL) {
+ return MAX_DECIMAL_SCALE;
+ }
+ throw new IllegalArgumentException("Unexpected column type: " +
columnType);
+ }
+ }
+
+ /**
+ * Returns the minimum supported scale for given type or {@link
#UNSPECIFIED_SCALE} if the type does not support scale.
+ *
+ * @param columnType Column type
+ * @return Minimum scale
Review Comment:
```suggestion
* @param columnType Column type.
* @return Minimum scale.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]