private void autoCreateDatabase()
      throws LoadAnalyzeException, LoadFileException, IllegalPathException, AuthException {
    final int databasePrefixNodesLength = loadTsFileAnalyzer.getDatabaseLevel() + 1;
    final Set<PartialPath> databasesNeededToBeSet = new HashSet<>();

    for (final IDeviceID device : schemaCache.getDevice2TimeSeries().keySet()) {
      final PartialPath devicePath = new PartialPath(device);

      final String[] devicePrefixNodes = devicePath.getNodes();
      if (devicePrefixNodes.length < databasePrefixNodesLength) {
        throw new LoadAnalyzeException(
            String.format(
                "Database level %d is longer than device %s.", databasePrefixNodesLength, device));
      }

      final String[] databasePrefixNodes = new String[databasePrefixNodesLength];
      System.arraycopy(devicePrefixNodes, 0, databasePrefixNodes, 0, databasePrefixNodesLength);

      databasesNeededToBeSet.add(new PartialPath(databasePrefixNodes));
    }

    // 1. filter out the databases that already exist
    if (schemaCache.getAlreadySetDatabases().isEmpty()) {
      try (final ConfigNodeClient configNodeClient =
          CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
        final TGetDatabaseReq req =
            new TGetDatabaseReq(
                Arrays.asList(
                    new ShowDatabaseStatement(new PartialPath(SqlConstant.getSingleRootArray()))
                        .getPathPattern()
                        .getNodes()),
                SchemaConstant.ALL_MATCH_SCOPE.serialize());
        final TShowDatabaseResp resp = configNodeClient.showDatabase(req);

        for (final String databaseName : resp.getDatabaseInfoMap().keySet()) {
          schemaCache.addAlreadySetDatabase(new PartialPath(databaseName));
        }
      } catch (IOException | TException | ClientManagerException e) {
        throw new LoadFileException(e);
      }
    }
    databasesNeededToBeSet.removeAll(schemaCache.getAlreadySetDatabases());

    // 2. create the databases that do not exist
    for (final PartialPath databasePath : databasesNeededToBeSet) {
      final DatabaseSchemaStatement statement =
          new DatabaseSchemaStatement(DatabaseSchemaStatement.DatabaseSchemaStatementType.CREATE);
      statement.setDatabasePath(databasePath);
      // do not print exception log because it is not an error
      statement.setEnablePrintExceptionLog(false);
      executeSetDatabaseStatement(statement);

      schemaCache.addAlreadySetDatabase(databasePath);
    }
  }
This can only be invoked after all timeseries in the current tsfile have been processed.
Otherwise, the isAligned status may be wrong.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/load/TreeSchemaAutoCreatorAndVerifier.java