You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "zstan (via GitHub)" <gi...@apache.org> on 2025/05/21 14:04:05 UTC
[PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
zstan opened a new pull request, #5870:
URL: https://github.com/apache/ignite-3/pull/5870
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104407833
##########
modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/SchemaTestUtils.java:
##########
@@ -138,7 +138,7 @@ public static Object generateRandomValue(Random rnd, NativeType type) {
}
/** Creates a native type from given type spec. */
- public static NativeType specToType(NativeTypeSpec spec) {
+ public static NativeType specToType(ColumnType spec) { // todo ????
Review Comment:
replace comment
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104568670
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -138,12 +138,12 @@ public static class ConstantValue extends DefaultValue {
private ConstantValue(@Nullable Object value) {
super(Type.CONSTANT);
- NativeType nativeType = NativeTypes.fromObject(value);
+ NativeType type0 = NativeTypes.fromObject(value);
Review Comment:
Is is possible to create a similar method to get ColumnType by the object value\class?
to avoid the next `if-statement` and `.spec()` call...
Or we must be sure the storage supports the object type?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104693868
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java:
##########
@@ -205,8 +205,12 @@ public int hashCode() {
* @param val Object to validate.
*/
public void validate(@Nullable Object val) {
- if (val == null && !nullable) {
- throw new SchemaMismatchException(nullConstraintViolationMessage(name));
+ if (val == null) {
Review Comment:
I agree, this is very strange place, but it also not relates to initial issue and was approved by 2 reviewers ...
you can fill a different issue and it will be done there.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104568670
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -138,12 +138,12 @@ public static class ConstantValue extends DefaultValue {
private ConstantValue(@Nullable Object value) {
super(Type.CONSTANT);
- NativeType nativeType = NativeTypes.fromObject(value);
+ NativeType type0 = NativeTypes.fromObject(value);
Review Comment:
Is is possible to create a similar method to get ColumnType by the object value\class?
to avoid the next `if-statement` and `.spec()` call...
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104406273
##########
modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java:
##########
@@ -546,8 +546,10 @@ private static class Value {
private UUID fuuidN;
private String fstring;
private String fstringN;
- private byte[] fbytes;
- private byte[] fbytesN;
+ //CHECKSTYLE:OFF
+ private byte[] fbyte_array;
+ private byte[] fbyte_arrayN;
Review Comment:
unfortunately it`s not true, test use auto-generated names according to types, i not dig deeper just write this annotation.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104409373
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -150,8 +164,14 @@ public int id() {
return id;
}
- /** Returns corresponding {@code ColumnType} by given id, {@code null} for unknown id. */
- public static @Nullable ColumnType getById(int id) {
+ /** Returns the {@link ColumnType} instance by its id, or {@code null} if the id is invalid. */
+ public static @Nullable ColumnType fromId(int id) {
return id >= 0 && id < VALS.length ? VALS[id] : null;
}
+
+ // TODO https://issues.apache.org/jira/browse/IGNITE-17373 Remove filter after this issue is resolved
+ @TestOnly
Review Comment:
move to NativeType
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104606878
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java:
##########
@@ -205,8 +205,12 @@ public int hashCode() {
* @param val Object to validate.
*/
public void validate(@Nullable Object val) {
- if (val == null && !nullable) {
- throw new SchemaMismatchException(nullConstraintViolationMessage(name));
+ if (val == null) {
Review Comment:
I'm ok to fix this in another ticket.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2103988127
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -150,8 +164,14 @@ public int id() {
return id;
}
- /** Returns corresponding {@code ColumnType} by given id, {@code null} for unknown id. */
- public static @Nullable ColumnType getById(int id) {
+ /** Returns the {@link ColumnType} instance by its id, or {@code null} if the id is invalid. */
+ public static @Nullable ColumnType fromId(int id) {
return id >= 0 && id < VALS.length ? VALS[id] : null;
}
+
+ // TODO https://issues.apache.org/jira/browse/IGNITE-17373 Remove filter after this issue is resolved
+ @TestOnly
Review Comment:
I believe we must not put `@TestOnly` stuff in public api classes and interfaces
##########
modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/SchemaTestUtils.java:
##########
@@ -138,7 +138,7 @@ public static Object generateRandomValue(Random rnd, NativeType type) {
}
/** Creates a native type from given type spec. */
- public static NativeType specToType(NativeTypeSpec spec) {
+ public static NativeType specToType(ColumnType spec) { // todo ????
Review Comment:
> // todo ????
may you elaborate here please what is wrong with this method?
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -123,6 +128,15 @@ public enum ColumnType {
this.scaleAllowed = scaleDefined;
this.lengthAllowed = lengthDefined;
this.id = id;
+
+ fixedSize = !((precisionAllowed && scaleAllowed) || lengthAllowed);
+ }
+
+ /**
+ * Get fixed length flag: {@code true} for fixed-length types, {@code false} otherwise.
+ */
+ public boolean fixedLength() {
Review Comment:
`fixedLength` is kinda legacy reminding us about old format. I would prefer to avoid adding such methods to public api classes since it will be replay hard to get rid of this. Let's move this method to `NativeType` class
##########
modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java:
##########
@@ -546,8 +546,10 @@ private static class Value {
private UUID fuuidN;
private String fstring;
private String fstringN;
- private byte[] fbytes;
- private byte[] fbytesN;
+ //CHECKSTYLE:OFF
+ private byte[] fbyte_array;
+ private byte[] fbyte_arrayN;
Review Comment:
this refactoring is not really required for this patch, so let's revert it
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -150,8 +164,14 @@ public int id() {
return id;
}
- /** Returns corresponding {@code ColumnType} by given id, {@code null} for unknown id. */
- public static @Nullable ColumnType getById(int id) {
+ /** Returns the {@link ColumnType} instance by its id, or {@code null} if the id is invalid. */
+ public static @Nullable ColumnType fromId(int id) {
Review Comment:
`ColumnType` is part of public api, therefore it's a breaking change. Please revert it
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -138,12 +138,12 @@ public static class ConstantValue extends DefaultValue {
private ConstantValue(@Nullable Object value) {
super(Type.CONSTANT);
- NativeType nativeType = NativeTypes.fromObject(value);
+ @Nullable NativeType type0 = NativeTypes.fromObject(value);
Review Comment:
we don't usually put `@Nullable` for local variables
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ValueSerializationHelper.java:
##########
@@ -62,7 +62,7 @@ public static String toString(Object defaultValue, NativeType type) {
case STRING:
case UUID:
return defaultValue.toString();
Review Comment:
is this helper used anywhere? If not let's just remove it
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan merged PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104408694
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -123,6 +128,15 @@ public enum ColumnType {
this.scaleAllowed = scaleDefined;
this.lengthAllowed = lengthDefined;
this.id = id;
+
+ fixedSize = !((precisionAllowed && scaleAllowed) || lengthAllowed);
+ }
+
+ /**
+ * Get fixed length flag: {@code true} for fixed-length types, {@code false} otherwise.
+ */
+ public boolean fixedLength() {
Review Comment:
moved
##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnType.java:
##########
@@ -150,8 +164,14 @@ public int id() {
return id;
}
- /** Returns corresponding {@code ColumnType} by given id, {@code null} for unknown id. */
- public static @Nullable ColumnType getById(int id) {
+ /** Returns the {@link ColumnType} instance by its id, or {@code null} if the id is invalid. */
+ public static @Nullable ColumnType fromId(int id) {
Review Comment:
done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104408141
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/ValueSerializationHelper.java:
##########
@@ -62,7 +62,7 @@ public static String toString(Object defaultValue, NativeType type) {
case STRING:
case UUID:
return defaultValue.toString();
Review Comment:
removed
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -138,12 +138,12 @@ public static class ConstantValue extends DefaultValue {
private ConstantValue(@Nullable Object value) {
super(Type.CONSTANT);
- NativeType nativeType = NativeTypes.fromObject(value);
+ @Nullable NativeType type0 = NativeTypes.fromObject(value);
Review Comment:
done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104425681
##########
modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java:
##########
@@ -546,8 +546,10 @@ private static class Value {
private UUID fuuidN;
private String fstring;
private String fstringN;
- private byte[] fbytes;
- private byte[] fbytesN;
+ //CHECKSTYLE:OFF
+ private byte[] fbyte_array;
+ private byte[] fbyte_arrayN;
Review Comment:
ah, I see
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104606237
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java:
##########
@@ -205,8 +205,12 @@ public int hashCode() {
* @param val Object to validate.
*/
public void validate(@Nullable Object val) {
- if (val == null && !nullable) {
- throw new SchemaMismatchException(nullConstraintViolationMessage(name));
+ if (val == null) {
Review Comment:
I don't like this method.
We should validate value range the same way in SQL and in KV.
Can we check here only typeSpec equality (+ maybe nullability), and then pass `val` object to `NativeType.validate` method as `Column.type.validate(val);`
NativeType implementations could override the method to check bounds or length or whatever else.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24377 Sql. Get rid of NativeTypeSpec [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan commented on code in PR #5870:
URL: https://github.com/apache/ignite-3/pull/5870#discussion_r2104680344
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -138,12 +138,12 @@ public static class ConstantValue extends DefaultValue {
private ConstantValue(@Nullable Object value) {
super(Type.CONSTANT);
- NativeType nativeType = NativeTypes.fromObject(value);
+ NativeType type0 = NativeTypes.fromObject(value);
Review Comment:
I don\`t like this idea - to implement huge method for only this one case, anyway such request is beyond the scope of issue, previous implementation was the same
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org