Skip to content
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

[Fix] Fix read from Oracle Date type value lose time #5814

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public SeaTunnelDataType<?> toSeaTunnelType(
case ORACLE_XML:
return BasicType.STRING_TYPE;
case ORACLE_DATE:
return LocalTimeType.LOCAL_DATE_TYPE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there compatibility with older versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is compatible for the reading data end, but may not be compatible for the downstream writing data end because the data content has changed. But the purpose of this PR is to correct previous wrong behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

case ORACLE_TIMESTAMP:
case ORACLE_TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return LocalTimeType.LOCAL_DATE_TIME_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public class OracleTypeMapper implements JdbcDialectTypeMapper {
public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex)
throws SQLException {
String oracleType = metadata.getColumnTypeName(colIndex).toUpperCase();
String columnName = metadata.getColumnName(colIndex);
int precision = metadata.getPrecision(colIndex);
int scale = metadata.getScale(colIndex);
switch (oracleType) {
Expand Down Expand Up @@ -110,7 +109,6 @@ public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex)
case ORACLE_XML:
return BasicType.STRING_TYPE;
case ORACLE_DATE:
return LocalTimeType.LOCAL_DATE_TYPE;
case ORACLE_TIMESTAMP:
case ORACLE_TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return LocalTimeType.LOCAL_DATE_TIME_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ public class JdbcOracleIT extends AbstractJdbcIT {
+ " XML_TYPE_COL \"SYS\".\"XMLTYPE\"\n"
+ ")";

private static final String[] fieldNames =
new String[] {
"VARCHAR_10_COL",
"CHAR_10_COL",
"CLOB_COL",
"NUMBER_3_SF_2_DP",
"INTEGER_COL",
"FLOAT_COL",
"REAL_COL",
"BINARY_FLOAT_COL",
"BINARY_DOUBLE_COL",
"DATE_COL",
"TIMESTAMP_WITH_3_FRAC_SEC_COL",
"TIMESTAMP_WITH_LOCAL_TZ",
"XML_TYPE_COL"
};

@Override
JdbcCase getJdbcCase() {
Map<String, String> containerEnv = new HashMap<>();
Expand Down Expand Up @@ -117,7 +134,9 @@ JdbcCase getJdbcCase() {
}

@Override
void compareResult(String executeKey) {}
void compareResult(String executeKey) {
defaultCompare(executeKey, fieldNames, "INTEGER_COL");
}

@Override
String driverUrl() {
Expand All @@ -126,23 +145,6 @@ String driverUrl() {

@Override
Pair<String[], List<SeaTunnelRow>> initTestData() {
String[] fieldNames =
new String[] {
"VARCHAR_10_COL",
"CHAR_10_COL",
"CLOB_COL",
"NUMBER_3_SF_2_DP",
"INTEGER_COL",
"FLOAT_COL",
"REAL_COL",
"BINARY_FLOAT_COL",
"BINARY_DOUBLE_COL",
"DATE_COL",
"TIMESTAMP_WITH_3_FRAC_SEC_COL",
"TIMESTAMP_WITH_LOCAL_TZ",
"XML_TYPE_COL"
};

List<SeaTunnelRow> rows = new ArrayList<>();
for (int i = 0; i < 100; i++) {
SeaTunnelRow row =
Expand Down