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

Make the Background code examples in Calcite official documentation clearer

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.39.0
    • None

    Description

      public static class HrSchema {
        public final Employee[] emps = 0;
        public final Department[] depts = 0;
      }
      Class.forName("org.apache.calcite.jdbc.Driver");
      Properties info = new Properties();
      info.setProperty("lex", "JAVA");
      Connection connection =
          DriverManager.getConnection("jdbc:calcite:", info);
      CalciteConnection calciteConnection =
          connection.unwrap(CalciteConnection.class);
      SchemaPlus rootSchema = calciteConnection.getRootSchema();
      Schema schema = new ReflectiveSchema(new HrSchema());
      rootSchema.add("hr", schema);
      Statement statement = calciteConnection.createStatement();
      ResultSet resultSet = statement.executeQuery(
          "select d.deptno, min(e.empid)\n"
          + "from hr.emps as e\n"
          + "join hr.depts as d\n"
          + "  on e.deptno = d.deptno\n"
          + "group by d.deptno\n"
          + "having count(*) > 1");
      print(resultSet);
      resultSet.close();
      statement.close();
      connection.close();
      

      Currently, the data of emps and depts are both 0, and it is not reasonable to not create a new object. We can create new Employee[0] and add some data, which may be more reasonable.

      Attachments

        Issue Links

          Activity

            People

              caicancai Caican Cai
              caicancai Caican Cai
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: