You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Gavin Ray (Jira)" <ji...@apache.org> on 2022/02/25 02:33:00 UTC
[jira] [Created] (CALCITE-5022) JSON values from queries against H2 (possibly other) schemas encoded as bytes (IE: "B@6e9a0bea")
Gavin Ray created CALCITE-5022:
----------------------------------
Summary: JSON values from queries against H2 (possibly other) schemas encoded as bytes (IE: "B@6e9a0bea")
Key: CALCITE-5022
URL: https://issues.apache.org/jira/browse/CALCITE-5022
Project: Calcite
Issue Type: Bug
Components: avatica, core, jdbc-driver
Affects Versions: 1.30.0
Reporter: Gavin Ray
Reproduction below:
{code:java}
@Test void someTestH2() throws Exception {
String url = "jdbc:calcite:";
Connection conn = DriverManager.getConnection(url);
DataSource ds = JdbcSchema.dataSource("jdbc:h2:mem:test", null, null, null);
ds.getConnection().createStatement().execute("""
CREATE TABLE "users" (
"id" INTEGER NOT NULL,
"name" VARCHAR(255) NOT NULL
);
""");
ds.getConnection().createStatement().execute("""
INSERT INTO "users" VALUES (1, 'Alice');
INSERT INTO "users" VALUES (2, 'Bob');
INSERT INTO "users" VALUES (3, 'Carol');
""");
CalciteConnection calciteConnection = conn.unwrap(CalciteConnection.class);
JdbcSchema jdbcSchema = JdbcSchema.create(calciteConnection.getRootSchema(), "h2", ds, null, null);
calciteConnection.getRootSchema().add("h2", jdbcSchema);
var rs = calciteConnection.createStatement().executeQuery(
"""
SELECT
"id",
"name",
JSON_OBJECT(
KEY 'level1'
VALUE 1
)
FROM
"h2"."users"
"""
);
while (rs.next()) {
var md = rs.getMetaData();
for (int i = 1; i <= md.getColumnCount(); i++) {
System.out.println(md.getColumnName(i) + ": " + rs.getObject(i));
}
System.out.println("---");
}
}
{code}
{code:java}
id: 1
name: Alice
EXPR$2: [B@6e9a0bea
---
id: 2
name: Bob
EXPR$2: [B@28fc1132
---
id: 3
name: Carol
EXPR$2: [B@355ce6a6
---
{code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)