-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: support many more TEXT functions
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
- Loading branch information
1 parent
0599f38
commit 40e39f4
Showing
8 changed files
with
848 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ bin/ | |
|
||
**/changelog.rst | ||
**/javadoc.rst | ||
**/.~lock.JSQLTranspiler.ods# | ||
**/.~lock.JSQLTranspiler.ods# | ||
/.idea |
306 changes: 296 additions & 10 deletions
306
src/main/java/com/manticore/transpiler/ExpressionTranspiler.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file not shown.
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,45 @@ | ||
package com.manticore.transpiler; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.Timeout; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Disabled | ||
public class DuckDBFreeze { | ||
|
||
@Test | ||
@Timeout(value = 10, unit = TimeUnit.SECONDS) | ||
void testFreeze() throws SQLException { | ||
String sqlString = | ||
"WITH example AS\n" + " (SELECT 'абвгд' AS characters, encode('абвгд') bytes)\n" | ||
+ "SELECT\n" + " characters,\n" + " bit_length(characters) AS string_example,\n" | ||
+ " bytes,\n" + " bit_length(bytes) AS bytes_example\n" + "FROM example;\n"; | ||
|
||
try (Connection connDuck = DriverManager.getConnection("jdbc:duckdb:"); | ||
Statement st = connDuck.createStatement(); | ||
ResultSet rs = st.executeQuery(sqlString);) { | ||
Assertions.assertTrue(rs.next()); | ||
} | ||
} | ||
|
||
@Test | ||
void testSalaaU() { | ||
final String regex = "ู"; | ||
final String string = "ศูพรรณี"; | ||
|
||
final Pattern pattern = Pattern.compile(regex); | ||
final Matcher matcher = pattern.matcher(string); | ||
|
||
Assertions.assertTrue(matcher.find()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,6 @@ | ||
-- provided | ||
SELECT | ||
TIMESTAMP('2008-12-25 15:30:00+00') as t1, | ||
TIMESTAMP('2008-12-25 15:30:00+00', 'America/Los_Angeles') as t2, | ||
TIMESTAMP(DATE '2008-12-25 15:30:00+00') AS t3, | ||
TIMESTAMP(DATE '2008-12-25 15:30:00+00', 'America/Los_Angeles') AS t4, | ||
TIMESTAMP(DATETIME '2008-12-25 15:30:00+00') AS t5, | ||
TIMESTAMP(DATETIME '2008-12-25 15:30:00+00', 'America/Los_Angeles') AS t6; | ||
|
||
-- expected | ||
SELECT | ||
CAST('2008-12-25 15:30:00+00' AS TIMESTAMPTZ) as t1, | ||
CAST('2008-12-25 15:30:00+00' AS TIMESTAMPTZ) AT TIME ZONE 'America/Los_Angeles' as t2, | ||
CAST(DATE '2008-12-25 15:30:00+00' AS TIMESTAMPTZ) AS t3, | ||
CAST(DATE '2008-12-25 15:30:00+00' AS TIMESTAMPTZ) AT TIME ZONE 'America/Los_Angeles' AS t4, | ||
CAST(DATETIME '2008-12-25 15:30:00+00' AS TIMESTAMPTZ) AS t5, | ||
CAST(DATETIME '2008-12-25 15:30:00+00' AS TIMESTAMPTZ) AT TIME ZONE 'America/Los_Angeles' AS t6; | ||
SELECT ASCII('abcd') as A, ASCII('a') as B, ASCII('') as C, ASCII(NULL) as D; | ||
|
||
-- result | ||
"t1","t2","t3","t4","t5","t6" | ||
"2008-12-25T15:30Z","2008-12-25 07:30:00","2008-12-25T00:00Z","2008-12-24 16:00:00","2008-12-25T08:30Z","2008-12-25 00:30:00" | ||
"A","B","C","D" | ||
"97","97","0","" |
Oops, something went wrong.