-
Notifications
You must be signed in to change notification settings - Fork 25k
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
SQL: Improve correctness of SYS COLUMNS & TYPES #30418
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24fc863
SQL: Improve correctness of SYS COLUMNS & TYPES
costin 19d4700
Update changelog
costin 45096c9
Fix license header and update precision for Dates
costin 8a2077a
A bit more tweaking of returned values
costin c90a4b8
Merge remote-tracking branch 'remotes/upstream/master' into fix-30386
costin 649caf4
Merge branch 'master' into fix-30386
costin 9e02fc8
Merge remote-tracking branch 'remotes/upstream/master' into fix-30386
costin 74870f3
Update metadata test
costin 4c1572b
Merge remote-tracking branch 'remotes/upstream/master' into fix-30386
costin 61f4eb5
Fix order for SYS TYPES and TABLES according to the JDBC/ODBC spec
costin 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 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 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 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 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 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
70 changes: 70 additions & 0 deletions
70
x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/type/DataTypesTests.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* ELASTICSEARCH CONFIDENTIAL | ||
* __________________ | ||
* | ||
* [2017] Elasticsearch Incorporated. All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Elasticsearch Incorporated and its suppliers, | ||
* if any. The intellectual and technical concepts contained | ||
* herein are proprietary to Elasticsearch Incorporated | ||
* and its suppliers and may be covered by U.S. and Foreign Patents, | ||
* patents in process, and are protected by trade secret or copyright law. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Elasticsearch Incorporated. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.sql.type; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import static org.elasticsearch.xpack.sql.type.DataType.DATE; | ||
import static org.elasticsearch.xpack.sql.type.DataType.FLOAT; | ||
import static org.elasticsearch.xpack.sql.type.DataType.KEYWORD; | ||
import static org.elasticsearch.xpack.sql.type.DataType.LONG; | ||
import static org.elasticsearch.xpack.sql.type.DataTypes.metaSqlDataType; | ||
import static org.elasticsearch.xpack.sql.type.DataTypes.metaSqlDateTimeSub; | ||
import static org.elasticsearch.xpack.sql.type.DataTypes.metaSqlMaximumScale; | ||
import static org.elasticsearch.xpack.sql.type.DataTypes.metaSqlMinimumScale; | ||
import static org.elasticsearch.xpack.sql.type.DataTypes.metaSqlRadix; | ||
|
||
public class DataTypesTests extends ESTestCase { | ||
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. @bpintea This test might be easier to read with regards to the expected behavior. 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. The tests are inline with my understanding as well. |
||
|
||
public void testMetaDataType() { | ||
assertEquals(Integer.valueOf(9), metaSqlDataType(DATE)); | ||
DataType t = randomDataTypeNoDate(); | ||
assertEquals(t.jdbcType.getVendorTypeNumber(), metaSqlDataType(t)); | ||
} | ||
|
||
public void testMetaDateTypeSub() { | ||
assertEquals(Integer.valueOf(3), metaSqlDateTimeSub(DATE)); | ||
assertEquals(Integer.valueOf(0), metaSqlDateTimeSub(randomDataTypeNoDate())); | ||
} | ||
|
||
public void testMetaMinimumScale() { | ||
assertEquals(Short.valueOf((short) 3), metaSqlMinimumScale(DATE)); | ||
assertEquals(Short.valueOf((short) 0), metaSqlMinimumScale(LONG)); | ||
assertEquals(Short.valueOf((short) 0), metaSqlMinimumScale(FLOAT)); | ||
assertNull(metaSqlMinimumScale(KEYWORD)); | ||
} | ||
|
||
public void testMetaMaximumScale() { | ||
assertEquals(Short.valueOf((short) 3), metaSqlMaximumScale(DATE)); | ||
assertEquals(Short.valueOf((short) 0), metaSqlMaximumScale(LONG)); | ||
assertEquals(Short.valueOf((short) FLOAT.defaultPrecision), metaSqlMaximumScale(FLOAT)); | ||
assertNull(metaSqlMaximumScale(KEYWORD)); | ||
} | ||
|
||
public void testMetaRadix() { | ||
assertNull(metaSqlRadix(DATE)); | ||
assertNull(metaSqlRadix(KEYWORD)); | ||
assertEquals(Integer.valueOf(10), metaSqlRadix(LONG)); | ||
assertEquals(Integer.valueOf(2), metaSqlRadix(FLOAT)); | ||
} | ||
|
||
private DataType randomDataTypeNoDate() { | ||
return randomValueOtherThan(DataType.DATE, () -> randomFrom(DataType.values())); | ||
} | ||
} | ||
|
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.
@bpintea Can you please double check whether the metadata methods are correct?
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.
Yes, with the date fix, it's all correct.