Skip to content

Commit b287779

Browse files
feat: allow file names as Table supporting CSV or Parquet files
Signed-off-by: Andreas Reichel <[email protected]> Signed-off-by: manticore-projects <[email protected]>
1 parent 5d080b3 commit b287779

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ test {
189189

190190
// set heap size for the test JVM(s)
191191
minHeapSize = "128m"
192-
maxHeapSize = "1G"
192+
maxHeapSize = "4G"
193193

194194
jacoco {
195195
excludes = ['net/sf/jsqlparser/parser/CCJSqlParserTokenManager']

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Specifies the JVM arguments used for the daemon process.
22
# The setting is particularly useful for tweaking memory settings.
3-
org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1024m -XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096 -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError
3+
org.gradle.jvmargs=-Xmx4G -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError
44

55
org.gradle.caching=false
66

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

+8-1
Original file line numberDiff line numberDiff line change
@@ -2116,15 +2116,22 @@ Table Table() #TableName :
21162116
{
21172117
//String serverName = null, databaseName = null, schemaName = null, tableName = null;
21182118
ObjectNames data = null;
2119+
Token fileNameToken = null;
21192120
}
21202121
{
21212122
data = RelObjectNames()
2122-
21232123
{
21242124
Table table = new Table(data.getNames());
21252125
linkAST(table,jjtThis);
21262126
return table;
21272127
}
2128+
|
2129+
fileNameToken = <S_CHAR_LITERAL>
2130+
{
2131+
Table table = new Table(fileNameToken.image);
2132+
linkAST(table,jjtThis);
2133+
return table;
2134+
}
21282135
}
21292136

21302137
Table TableWithAlias():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.sf.jsqlparser.statement.select;
2+
3+
import net.sf.jsqlparser.JSQLParserException;
4+
import net.sf.jsqlparser.schema.Table;
5+
import net.sf.jsqlparser.test.TestUtils;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
8+
9+
public class DuckDBTest {
10+
11+
@Test
12+
void testFileTable() throws JSQLParserException {
13+
String sqlStr = "SELECT * FROM '/tmp/test.parquet'";
14+
PlainSelect select = (PlainSelect) TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
15+
Table table = (Table) select.getFromItem();
16+
17+
Assertions.assertEquals("'/tmp/test.parquet'", table.getName());
18+
}
19+
}

0 commit comments

Comments
 (0)