-
Notifications
You must be signed in to change notification settings - Fork 96
docs(isthmus): javadoc for io.substrait.isthmus type system classes #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,28 +2,45 @@ | |
|
|
||
| import org.apache.calcite.avatica.util.TimeUnit; | ||
| import org.apache.calcite.jdbc.JavaTypeFactoryImpl; | ||
| import org.apache.calcite.rel.type.RelDataType; | ||
| import org.apache.calcite.rel.type.RelDataTypeFactory; | ||
| import org.apache.calcite.rel.type.RelDataTypeSystem; | ||
| import org.apache.calcite.rel.type.RelDataTypeSystemImpl; | ||
| import org.apache.calcite.sql.SqlIntervalQualifier; | ||
| import org.apache.calcite.sql.parser.SqlParserPos; | ||
| import org.apache.calcite.sql.type.SqlTypeName; | ||
|
|
||
| /** | ||
| * Custom {@link RelDataTypeSystem} implementation for Substrait. | ||
| * | ||
| * <p>Defines type system rules such as precision, scale, and interval qualifiers for Substrait | ||
| * integration with Calcite. | ||
| */ | ||
| public class SubstraitTypeSystem extends RelDataTypeSystemImpl { | ||
|
|
||
| /** Singleton instance of Substrait type system. */ | ||
| public static final RelDataTypeSystem TYPE_SYSTEM = new SubstraitTypeSystem(); | ||
|
|
||
| /** Default type factory using the Substrait type system. */ | ||
| public static final RelDataTypeFactory TYPE_FACTORY = new JavaTypeFactoryImpl(TYPE_SYSTEM); | ||
|
|
||
| // Interval qualifier from year to month | ||
| /** Interval qualifier from year to month. */ | ||
| public static final SqlIntervalQualifier YEAR_MONTH_INTERVAL = | ||
| new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, SqlParserPos.ZERO); | ||
|
|
||
| // Interval qualifier from day to fractional second at microsecond precision | ||
| /** Interval qualifier from day to fractional second at microsecond precision. */ | ||
| public static final SqlIntervalQualifier DAY_SECOND_INTERVAL = | ||
| new SqlIntervalQualifier(TimeUnit.DAY, -1, TimeUnit.SECOND, 6, SqlParserPos.ZERO); | ||
|
|
||
| /** Private constructor to enforce singleton usage. */ | ||
| private SubstraitTypeSystem() {} | ||
|
|
||
| /** | ||
| * Returns the maximum precision for the given SQL type. | ||
| * | ||
| * @param typeName The {@link SqlTypeName} for which precision is requested. | ||
| * @return Maximum precision for the type. | ||
| */ | ||
| @Override | ||
| public int getMaxPrecision(final SqlTypeName typeName) { | ||
| switch (typeName) { | ||
|
|
@@ -41,6 +58,13 @@ public int getMaxPrecision(final SqlTypeName typeName) { | |
| return super.getMaxPrecision(typeName); | ||
| } | ||
|
|
||
| /** | ||
| * Returns default precision for this type if supported, otherwise {@link | ||
| * RelDataType#PRECISION_NOT_SPECIFIED} if precision is either unsupported or must be specified | ||
| * explicitly. | ||
| * | ||
| * @return Default precision | ||
| */ | ||
| @Override | ||
| public int getDefaultPrecision(final SqlTypeName typeName) { | ||
| switch (typeName) { | ||
|
|
@@ -51,6 +75,14 @@ public int getDefaultPrecision(final SqlTypeName typeName) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns the maximum scale allowed for this type, or {@link RelDataType#SCALE_NOT_SPECIFIED} if | ||
| * scale is not applicable for this type. | ||
| * | ||
| * <p>The maximum scale for the decimal type is 38. | ||
| * | ||
| * @return Maximum allowed scale | ||
| */ | ||
|
Comment on lines
+78
to
+85
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This description is incorrect. The parent interface Javadoc says: /**
* Returns the maximum scale allowed for this type, or
* {@link RelDataType#SCALE_NOT_SPECIFIED}
* if scale is not applicable for this type.
*
* @return Maximum allowed scale
*/The maximum scale for the decimal type (in the current implementation) is 38. For all other types it is different. |
||
| @Override | ||
| public int getMaxScale(final SqlTypeName typeName) { | ||
| switch (typeName) { | ||
|
|
@@ -60,6 +92,11 @@ public int getMaxScale(final SqlTypeName typeName) { | |
| return super.getMaxScale(typeName); | ||
| } | ||
|
|
||
| /** | ||
| * Indicates whether ragged union types should be converted to varying types. | ||
| * | ||
| * @return {@code true}, as Substrait requires conversion to varying types. | ||
| */ | ||
| @Override | ||
| public boolean shouldConvertRaggedUnionTypesToVarying() { | ||
| return true; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description is incorrect. The parent interface Javadoc says:
Also, the return value (in the current implementation) is 38 for the decimal type, but not for any other type.