CategoricalData / CQL

Categorical Query Language IDE
http://categoricaldata.net
299 stars 23 forks source link

org.postgresql.util.PSQLException: ERROR: type "double" does not exist #47

Closed o1lo01ol1o closed 3 years ago

o1lo01ol1o commented 4 years ago

is thrown by

command store1 = export_jdbc_instance CoProd "jdbc:postgresql://localhost/foo" ""

I'm using the following in my typeside:

java_types
        Integer = "java.lang.Integer"
        Double = "java.lang.Double"
        Varchar = "java.lang.String"
java_constants
            Integer = "return java.lang.Integer.parseInteger(input[0])"
        Double = "return java.lang.Double.parseDouble(input[0])"
        Varchar = "return input[0]"

Should I be using a different type or should CQL tell the JDBC posgres driver to use "double precision" (instead of "double")?

wisnesky commented 4 years ago

That’s definitely an error, and probably related to CQL<-> Postgres driver interaction. The sql typeside does have a type “Double” (you can write "typeside x = sql” and run it to see everything in the sql typeside), and so my best guess is that CQL is generating SQL code containing the word ‘double’, but Postgres wants to see “double precision” or “double(32)” or something similar. Any chance you can generate a test case, or provide the stack trace (which should be on the console if you run CQL using java -jar cql.jar)? The fix is probably just another ‘if vendor = X write Z instead of Y in the generated SQL’, and there are many corner cases to check. On that note, thank you for being the first person to check them for postgres :-).

On Jul 11, 2020, at 9:44 AM, Tim Pierson notifications@github.com wrote:

is thrown by

command store1 = export_jdbc_instance CoProd "jdbc:postgresql://localhost/foo" ""

Should I be using a different type or should CQL tell the JDBC posgres driver to use "double precision" (instead of "double")?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CategoricalData/CQL/issues/47, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2QKNZY7LIG4NEVP5Q5KPTR3CJHBANCNFSM4OXMDZYQ.

o1lo01ol1o commented 4 years ago

so my best guess is that CQL is generating SQL code containing the word ‘double’, but Postgres wants to see “double precision” or “double(32)” or something similar.

Yes, that was my thought as well. Stack trace is below.

org.postgresql.util.PSQLException: ERROR: type "double" does not exist
  Position: 929
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
    at catdata.aql.fdm.ToJdbcPragmaInstance.deleteThenCreate(ToJdbcPragmaInstance.java:61)
    at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:75)
    at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:407)
    at java.base/java.lang.Thread.run(Thread.java:835)
java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: type "double" does not exist
  Position: 929
    at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:109)
    at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:407)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: org.postgresql.util.PSQLException: ERROR: type "double" does not exist
  Position: 929
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
    at catdata.aql.fdm.ToJdbcPragmaInstance.deleteThenCreate(ToJdbcPragmaInstance.java:61)
    at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:75)
    ... 2 more
catdata.LineException: org.postgresql.util.PSQLException: ERROR: type "double" does not exist
  Position: 929
    at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:437)
    at java.base/java.lang.Thread.run(Thread.java:835)
wisnesky commented 4 years ago

Yeah, that seems to be the problem. I’ll make the change, and in the interim you might try the ‘real’ type instead of double.

On Jul 11, 2020, at 1:31 PM, Tim Pierson notifications@github.com wrote:

so my best guess is that CQL is generating SQL code containing the word ‘double’, but Postgres wants to see “double precision” or “double(32)” or something similar.

Yes, that was my thought as well. Stack trace is below.

org.postgresql.util.PSQLException: ERROR: type "double" does not exist Position: 929 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268) at catdata.aql.fdm.ToJdbcPragmaInstance.deleteThenCreate(ToJdbcPragmaInstance.java:61) at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:75) at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:407) at java.base/java.lang.Thread.run(Thread.java:835) java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: type "double" does not exist Position: 929 at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:109) at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:407) at java.base/java.lang.Thread.run(Thread.java:835) Caused by: org.postgresql.util.PSQLException: ERROR: type "double" does not exist Position: 929 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268) at catdata.aql.fdm.ToJdbcPragmaInstance.deleteThenCreate(ToJdbcPragmaInstance.java:61) at catdata.aql.fdm.ToJdbcPragmaInstance.execute(ToJdbcPragmaInstance.java:75) ... 2 more catdata.LineException: org.postgresql.util.PSQLException: ERROR: type "double" does not exist Position: 929 at catdata.aql.exp.AqlMultiDriver.call(AqlMultiDriver.java:437) at java.base/java.lang.Thread.run(Thread.java:835) — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CategoricalData/CQL/issues/47#issuecomment-657125113, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2QKN5EE7ZHP4GNSH6DJPTR3DD2LANCNFSM4OXMDZYQ.

o1lo01ol1o commented 4 years ago

Real, Doubleprecision, and Float all fail; however, Decimal was acceptable.

wisnesky commented 3 years ago

Looks like "Double precision" was missing a space. I'll add a generic mechanism for bool(N), char(N) etc like we have with varchar(N). Marking as closed. The following works in the latest (internal) build `schema S = literal : Sql { entities E attributes att : E -> "Double precision" } instance I = literal : S { generators e:E equations e.att = "2.3" }

export the instance to SQL

command store1 = export_jdbc_instance I "" "Exported" { options start_ids_at = 100 } `