-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugs/6 exception with timestamps (#7)
* #5: updated vs-common versions * #6: throw an exception when Timestamp with local time zone is used * #6: added integration tests and documented new property Co-authored-by: Sebastian Bär <[email protected]>
- Loading branch information
1 parent
02ef9d2
commit 106292f
Showing
9 changed files
with
208 additions
and
77 deletions.
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitor.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,44 @@ | ||
package com.exasol.adapter.dialects.exasol; | ||
|
||
import static com.exasol.adapter.dialects.exasol.ExasolSqlDialect.EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import com.exasol.adapter.dialects.*; | ||
import com.exasol.adapter.sql.SqlLiteralTimestampUtc; | ||
|
||
/** | ||
* This class generates SQL queries for the {@link ExasolSqlDialect}. | ||
*/ | ||
public class ExasolSqlGenerationVisitor extends SqlGenerationVisitor { | ||
private static final Logger LOGGER = Logger.getLogger(ExasolSqlGenerationVisitor.class.getName()); | ||
|
||
/** | ||
* Creates a new instance of the {@link ExasolSqlGenerationVisitor}. | ||
* | ||
* @param dialect {@link ExasolSqlDialect} dialect | ||
* @param context SQL generation context | ||
*/ | ||
ExasolSqlGenerationVisitor(final SqlDialect dialect, | ||
final SqlGenerationContext context) { | ||
super(dialect, context); | ||
} | ||
|
||
@Override | ||
public String visit(final SqlLiteralTimestampUtc literal) { | ||
final ExasolSqlDialect exasolSqlDialect = (ExasolSqlDialect) getDialect(); | ||
if (exasolSqlDialect.isTimestampWithLocalTimeZoneEnabled()) { | ||
LOGGER.info("IGNORE_ERRORS = '" + EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH + "' property is enabled."); | ||
return super.visit(literal); | ||
} else { | ||
throw new UnsupportedOperationException( | ||
"Attention! Using literals and constant expressions with datatype `TIMESTAMP WITH LOCAL TIME ZONE` " + | ||
"in Virtual Schemas can produce an incorrect results. We recommend using 'TIMESTAMP' instead. " + | ||
"If you are willing to take the risk and want to use `TIMESTAMP WITH LOCAL TIME ZONE` anyway, please, " + | ||
"create a Virtual Schema with the following additional property " + | ||
"IGNORE_ERRORS = '" + EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH + "'. " + | ||
"We also recommend to set Exasol system `time_zone` " + | ||
"to UTC while working with `TIMESTAMP WITH LOCAL TIME ZONE`."); | ||
} | ||
} | ||
} |
55 changes: 21 additions & 34 deletions
55
src/test/java/com/exasol/adapter/dialects/exasol/ExasolFromExaQueryRewriterTest.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
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.