Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-3594

Select with Catalog fails

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: v2.6.0
    • Component/s: None
    • Labels:
      None

      Description

      By using DatabaseMetaData if we get catalog using getCatalogs() method, it return value "defaultCatalog". It returns actual hive schema when we execute getSchemas().
      According to JDBC contract, catalog.schema.table should be valid from clause and many query layers use that. But kylin fails when we execute that query.
      I've tried to write sample code piece for that below.
       
              DatabaseMetaData db = conn.getMetaData();
              ResultSet catalogSet = db.getCatalogs();
              String catalog = "";
              if(catalogSet.next()) {
                  catalog = catalogSet.getString("TABLE_CAT");
              }
              ResultSet schemaSet = db.getSchemas();
              String schema = "";
              if(schemaSet.next()) {
                  schema = schemaSet.getString("TABLE_SCHEM");
              }
              StringBuilder sb = new StringBuilder("SELECT * FROM ");
              if(!catalog.isEmpty()) {
                  sb.append(catalog + ".");
              }
              if(!schema.isEmpty()) {
                  sb.append(schema + ".");
              }
              sb.append("kylin_sales limit 10");
              String query = sb.toString();
              Statement stat = conn.createStatement();
              ResultSet rs = stat.executeQuery(query);
              while(rs.next()) {
                  System.out.println(rs.getObject("trans_id"));
              }
      In short, the above snippet is executing the query,
      select * from defaultCatalog.DEFAULT.kylin_sales.
       
      Same thing happens even with different schemas if we have like,
      select * from defaultCatalog.test.kylin_sales also fails.

        Attachments

          Activity

            People

            • Assignee:
              hit_lacus Xiaoxiang Yu
              Reporter:
              narahari92 Hosur Narahari
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: