infvg commented on code in PR #11373:
URL:
https://github.com/apache/incubator-gluten/pull/11373#discussion_r2695491116
##########
tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/TableCreator.scala:
##########
@@ -33,47 +37,44 @@ object TableCreator {
private object DiscoverSchema extends TableCreator {
override def create(spark: SparkSession, source: String, dataPath:
String): Unit = {
- val files = new File(dataPath).listFiles()
- val tableNames = files.map(_.getName)
+ val uri = URI.create(dataPath)
+ val fs = FileSystem.get(uri, new Configuration())
+
+ val basePath = new Path(dataPath)
+ val statuses = fs.listStatus(basePath)
+
+ val tableDirs = statuses.filter(_.isDirectory).map(_.getPath)
+
+ val tableNames = ArrayBuffer[String]()
+
val existedTableNames = mutable.ArrayBuffer[String]()
val createdTableNames = mutable.ArrayBuffer[String]()
val recoveredPartitionTableNames = mutable.ArrayBuffer[String]()
- if (tableNames.isEmpty) {
- return
- }
-
- println("Creating catalog tables: " + tableNames.mkString(", "))
-
- files.foreach(
- file => {
- val tableName = file.getName
+ tableDirs.foreach {
+ tablePath =>
+ val tableName = tablePath.getName
+ tableNames += tableName
if (spark.catalog.tableExists(tableName)) {
existedTableNames += tableName
} else {
- spark.catalog.createTable(tableName, file.getAbsolutePath, source)
+ spark.catalog.createTable(tableName, tablePath.toString, source)
createdTableNames += tableName
try {
spark.catalog.recoverPartitions(tableName)
recoveredPartitionTableNames += tableName
} catch {
case _: AnalysisException =>
- // Swallows analysis exceptions.
}
}
- })
-
- if (existedTableNames.nonEmpty) {
- println("Tables already exists: " + existedTableNames.mkString(", "))
- }
-
- if (createdTableNames.nonEmpty) {
- println("Tables created: " + createdTableNames.mkString(", "))
}
-
- if (recoveredPartitionTableNames.nonEmpty) {
+ println("Tables: " + tableNames.mkString(", "))
+ if (tableNames.isEmpty) return
+ if (existedTableNames.nonEmpty)
+ println("Tables already exists: " + existedTableNames.mkString(", "))
+ if (createdTableNames.nonEmpty) println("Tables created: " +
createdTableNames.mkString(", "))
+ if (recoveredPartitionTableNames.nonEmpty)
println("Recovered partition tables: " +
recoveredPartitionTableNames.mkString(", "))
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]