-
Notifications
You must be signed in to change notification settings - Fork 432
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
JSON datatype support #2558
Open
divang
wants to merge
24
commits into
main
Choose a base branch
from
user/divang/json-datatype-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
JSON datatype support #2558
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
17e21c1
JSON feature extension
lilgreenbird b480490
Added JSON data type support in DataTypes
1f2b95b
JSON startegy in DTV
e102633
Fix Json character encoding and JSON constants.
d994fec
Added JSON datatype test case
c164ef9
Added JSON datatype test cases in ResultSet, TVP and Regression scena…
f9db4f7
Added JSON datatype support
dff9280
Added JSON support in IOBuffer.java
0e7a053
Json datatype support: SQLServerCallableStatement
Ananya2 a8ebfd3
Updated callableStatementTest.java
Ananya2 952e37e
Merge branch 'main' into user/divang/json-datatype-support
44a185b
Added test cases for the TVP type in Callable Statements.
Ananya2 dc53208
Fixed JSON op.execute method mapping
508a1b9
Merge branch 'user/divang/json-datatype-support' of https://github.co…
fd21d1a
Fixed Store procedure output param TDS metadata and fixed bulk copy t…
07bea45
Fixed BulkCopy JSON datatype issue.
afb3753
Removed duplicate code and used existing method to solve Bulk opy iss…
9c4a401
Added test cases for Bulk copy
961f557
Enhanced JSON datatype regression test
a9042bf
Fixed formatting in dtv.java
a719e0a
Removed additional empty line in dtv.java
9bac0eb
Added JSON metadata test case
9bf9ffa
Merge remote-tracking branch 'origin/main' into user/divang/json-data…
cd28b53
Added JSON support for BulkCopyCSV, included test cases to validate i…
Ananya2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ enum TDSType { | |
NTEXT(0x63), // 99 | ||
UDT(0xF0), // -16 | ||
XML(0xF1), // -15 | ||
JSON(0xF4), // -12 | ||
|
||
// LONGLEN types | ||
SQL_VARIANT(0x62); // 98 | ||
|
@@ -148,7 +149,8 @@ enum SSType { | |
XML(Category.XML, "xml", JDBCType.LONGNVARCHAR), | ||
TIMESTAMP(Category.TIMESTAMP, "timestamp", JDBCType.BINARY), | ||
GEOMETRY(Category.UDT, "geometry", JDBCType.GEOMETRY), | ||
GEOGRAPHY(Category.UDT, "geography", JDBCType.GEOGRAPHY); | ||
GEOGRAPHY(Category.UDT, "geography", JDBCType.GEOGRAPHY), | ||
JSON(Category.JSON, "json", JDBCType.LONGNVARCHAR); | ||
|
||
final Category category; | ||
private final String name; | ||
|
@@ -204,7 +206,8 @@ enum Category { | |
TIMESTAMP, | ||
UDT, | ||
SQL_VARIANT, | ||
XML; | ||
XML, | ||
JSON; | ||
|
||
private static final Category[] VALUES = values(); | ||
} | ||
|
@@ -266,7 +269,12 @@ enum GetterConversion { | |
|
||
SQL_VARIANT(SSType.Category.SQL_VARIANT, EnumSet.of(JDBCType.Category.CHARACTER, JDBCType.Category.SQL_VARIANT, | ||
JDBCType.Category.NUMERIC, JDBCType.Category.DATE, JDBCType.Category.TIME, JDBCType.Category.BINARY, | ||
JDBCType.Category.TIMESTAMP, JDBCType.Category.NCHARACTER, JDBCType.Category.GUID)); | ||
JDBCType.Category.TIMESTAMP, JDBCType.Category.NCHARACTER, JDBCType.Category.GUID)), | ||
|
||
JSON(SSType.Category.JSON, EnumSet.of(JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER, | ||
JDBCType.Category.CLOB, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER, | ||
JDBCType.Category.NCLOB, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY, | ||
JDBCType.Category.BLOB, JDBCType.Category.JSON)); | ||
|
||
private final SSType.Category from; | ||
private final EnumSet<JDBCType.Category> to; | ||
|
@@ -450,6 +458,7 @@ JDBCType getJDBCType(SSType ssType, JDBCType jdbcTypeFromApp) { | |
case NVARCHAR: | ||
case NVARCHARMAX: | ||
case NTEXT: | ||
case JSON: | ||
jdbcType = JDBCType.LONGVARCHAR; | ||
break; | ||
|
||
|
@@ -673,8 +682,9 @@ enum JDBCType { | |
SQL_VARIANT(Category.SQL_VARIANT, microsoft.sql.Types.SQL_VARIANT, Object.class.getName()), | ||
GEOMETRY(Category.GEOMETRY, microsoft.sql.Types.GEOMETRY, Object.class.getName()), | ||
GEOGRAPHY(Category.GEOGRAPHY, microsoft.sql.Types.GEOGRAPHY, Object.class.getName()), | ||
LOCALDATETIME(Category.TIMESTAMP, java.sql.Types.TIMESTAMP, LocalDateTime.class.getName()); | ||
|
||
LOCALDATETIME(Category.TIMESTAMP, java.sql.Types.TIMESTAMP, LocalDateTime.class.getName()), | ||
JSON(Category.JSON, microsoft.sql.Types.JSON, Object.class.getName()); | ||
|
||
final Category category; | ||
private final int intValue; | ||
private final String className; | ||
|
@@ -722,7 +732,8 @@ enum Category { | |
GUID, | ||
SQL_VARIANT, | ||
GEOMETRY, | ||
GEOGRAPHY; | ||
GEOGRAPHY, | ||
JSON; | ||
|
||
private static final Category[] VALUES = values(); | ||
} | ||
|
@@ -733,7 +744,7 @@ enum SetterConversion { | |
JDBCType.Category.TIME, JDBCType.Category.TIMESTAMP, JDBCType.Category.DATETIMEOFFSET, | ||
JDBCType.Category.CHARACTER, JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER, | ||
JDBCType.Category.LONG_NCHARACTER, JDBCType.Category.BINARY, JDBCType.Category.LONG_BINARY, | ||
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT)), | ||
JDBCType.Category.GUID, JDBCType.Category.SQL_VARIANT, JDBCType.Category.JSON)), | ||
|
||
LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(JDBCType.Category.CHARACTER, | ||
JDBCType.Category.LONG_CHARACTER, JDBCType.Category.NCHARACTER, JDBCType.Category.LONG_NCHARACTER, | ||
|
@@ -795,7 +806,8 @@ enum SetterConversion { | |
|
||
GEOMETRY(JDBCType.Category.GEOMETRY, EnumSet.of(JDBCType.Category.GEOMETRY)), | ||
|
||
GEOGRAPHY(JDBCType.Category.GEOGRAPHY, EnumSet.of(JDBCType.Category.GEOGRAPHY)); | ||
GEOGRAPHY(JDBCType.Category.GEOGRAPHY, EnumSet.of(JDBCType.Category.GEOGRAPHY)), | ||
JSON(JDBCType.Category.JSON, EnumSet.of(JDBCType.Category.JSON)); | ||
|
||
private final JDBCType.Category from; | ||
private final EnumSet<JDBCType.Category> to; | ||
|
@@ -832,7 +844,7 @@ enum UpdaterConversion { | |
SSType.Category.DATETIMEOFFSET, SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER, | ||
SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER, SSType.Category.XML, | ||
SSType.Category.BINARY, SSType.Category.LONG_BINARY, SSType.Category.UDT, SSType.Category.GUID, | ||
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT)), | ||
SSType.Category.TIMESTAMP, SSType.Category.SQL_VARIANT, SSType.Category.JSON)), | ||
|
||
LONG_CHARACTER(JDBCType.Category.LONG_CHARACTER, EnumSet.of(SSType.Category.CHARACTER, | ||
SSType.Category.LONG_CHARACTER, SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER, | ||
|
@@ -895,7 +907,9 @@ enum UpdaterConversion { | |
SSType.Category.DATETIMEOFFSET, SSType.Category.CHARACTER, SSType.Category.LONG_CHARACTER, | ||
SSType.Category.NCHARACTER, SSType.Category.LONG_NCHARACTER)), | ||
|
||
SQL_VARIANT(JDBCType.Category.SQL_VARIANT, EnumSet.of(SSType.Category.SQL_VARIANT)); | ||
SQL_VARIANT(JDBCType.Category.SQL_VARIANT, EnumSet.of(SSType.Category.SQL_VARIANT)), | ||
|
||
JSON(JDBCType.Category.JSON, EnumSet.of(SSType.Category.JSON)); | ||
|
||
private final JDBCType.Category from; | ||
private final EnumSet<SSType.Category> to; | ||
|
@@ -970,7 +984,7 @@ boolean isBinary() { | |
* @return true if the JDBC type is textual | ||
*/ | ||
private final static EnumSet<Category> textualCategories = EnumSet.of(Category.CHARACTER, Category.LONG_CHARACTER, | ||
Category.CLOB, Category.NCHARACTER, Category.LONG_NCHARACTER, Category.NCLOB); | ||
Category.CLOB, Category.NCHARACTER, Category.LONG_NCHARACTER, Category.NCLOB, Category.JSON); //FIXME: JSON is textual? | ||
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. you have a //fixme comment. Was this resolved? how does textualCategories impact APIs ? |
||
|
||
boolean isTextual() { | ||
return textualCategories.contains(category); | ||
|
@@ -997,6 +1011,7 @@ int asJavaSqlType() { | |
return java.sql.Types.CHAR; | ||
case NVARCHAR: | ||
case SQLXML: | ||
case JSON: | ||
return java.sql.Types.VARCHAR; | ||
case LONGNVARCHAR: | ||
return java.sql.Types.LONGVARCHAR; | ||
|
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
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
Oops, something went wrong.
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.
What does it mean to have a LONG_BINARY on Json ? I see the other types using it as well, but wondering what its purpose is.