Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-16528

HiveClientImpl throws NPE when reading database from a custom metastore

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.0
    • SQL
    • None

    Description

      In HiveClientImpl there is a method to create database:

        override def createDatabase(
            database: CatalogDatabase,
            ignoreIfExists: Boolean): Unit = withHiveState {
          client.createDatabase(
            new HiveDatabase(
              database.name,
              database.description,
              database.locationUri,
              database.properties.asJava),
              ignoreIfExists)
        }
      

      The problem is that it assumes that database.properties is a not null value which is not always the truth. In fact, when the database is created, in HiveMetaStore we have:

          private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException {
            try {
              ms.getDatabase(DEFAULT_DATABASE_NAME);
            } catch (NoSuchObjectException e) {
              Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT,
                wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME).toString(), null);
              db.setOwnerName(PUBLIC);
              db.setOwnerType(PrincipalType.ROLE);
              ms.createDatabase(db);
            }
          }
      

      As you can see, parameters field is set to null.

      Attachments

        Activity

          People

            jlewandowski Jacek Lewandowski
            jlewandowski Jacek Lewandowski
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: