The following code (from a Kotlin Notebook) produces an error:
val languageWanted = DataFrame.readSqlQuery(
dbConfig,
"""
with languages as
(select unnest(regexp_split_to_array(language_wanted, ';')) as language from tr2025)
select language,
count(*)::float * 100 / (select count(*) from languages) as percentage
from languages
group by 1"""
)
The error is:
java.lang.IllegalArgumentException: SQL query should start from SELECT and contain one query for reading data without any manipulation. Also it should not contain any separators like `;`.
at org.jetbrains.kotlinx.dataframe.io.ReadJdbcKt.readSqlQuery(readJdbc.kt:314)
at org.jetbrains.kotlinx.dataframe.io.ReadJdbcKt.readSqlQuery(readJdbc.kt:240)
at org.jetbrains.kotlinx.dataframe.io.ReadJdbcKt.readSqlQuery$default(readJdbc.kt:229)
at Line_71_jupyter.<init>(Line_71.jupyter.kts:1) at Cell In[27], line 1
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:122)
The query fails both because it uses a Common table expression (with ...) and because it splits a string on semicolon (';'). Both of these are perfectly natural in a call to a database (in this case Postgresql) and the limitations should be removed.
The following code (from a Kotlin Notebook) produces an error:
The error is:
The query fails both because it uses a Common table expression (with ...) and because it splits a string on semicolon (';'). Both of these are perfectly natural in a call to a database (in this case Postgresql) and the limitations should be removed.