Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5022

JSON values from queries against H2 (possibly other) schemas encoded as bytes (IE: "B@6e9a0bea")

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.30.0
    • None
    • avatica, core, jdbc-driver
    • None

    Description

      Reproduction below:

      @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("---");
          }
      }
      
      id: 1
      name: Alice
      EXPR$2: [B@6e9a0bea
      ---
      id: 2
      name: Bob
      EXPR$2: [B@28fc1132
      ---
      id: 3
      name: Carol
      EXPR$2: [B@355ce6a6
      ---
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            gavinray Gavin Ray
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: