Qihoo360 / XSQL

Unified SQL Analytics Engine Based on SparkSQL
https://qihoo360.github.io/XSQL/
Apache License 2.0
209 stars 62 forks source link

[CORE] Optimize the code to make MongoManager more consistent with the design #71

Closed beliefer closed 4 years ago

beliefer commented 4 years ago

What changes were proposed in this pull request?

The current implement of MongoManager some violations of programming. The trait DataSourceManager define a template function listTables show below:

  /**
   * Display the tables of specified database.
   */
  override def listTables(db: String): Seq[String] = {
    throw new UnsupportedOperationException(s"List ${shortName()} table not supported!")
  }

  /**
   * Display the tables of specified database with pattern.
   */
  override def listTables(dbName: String, pattern: String): Seq[String] = {
    StringUtils.filterPattern(listTables(dbName), pattern)
  }

The design require the specific data source to implement listTables(db: String), but MongoManager overwrite the template function show below:

  override def listTables(dsName: String, dbName: String): Seq[String] = {
    val mongoDB = mongoClient.getDatabase(dbName)
    mongoDB.listCollectionNames().asScala.toSeq
  }

It will causes some bug. I think should to improve the implement to make MongoManager more consistent with the design.

How was this patch tested?

No UT.

WeiWenda commented 4 years ago

LGTM

beliefer commented 4 years ago

@WeiWenda Thanks.