wForget commented on code in PR #4932:
URL: https://github.com/apache/kyuubi/pull/4932#discussion_r1226054836


##########
extensions/spark/kyuubi-spark-lineage/src/main/scala/org/apache/kyuubi/plugin/lineage/dispatcher/atlas/AtlasEntityHelper.scala:
##########
@@ -104,33 +104,38 @@ object AtlasEntityHelper {
   }
 
   def tableObjectId(tableName: String): Option[AtlasObjectId] = {
-    val dbTb = tableName.split('.')
-    if (dbTb.length == 2) {
-      val qualifiedName = tableQualifiedName(cluster, dbTb(0), dbTb(1))
-      // TODO parse datasource type
-      Some(new AtlasObjectId(HIVE_TABLE_TYPE, "qualifiedName", qualifiedName))
-    } else {
-      None
+    tableName.split('.') match {
+      case Array(catalog, db, table) =>
+        val qualifiedName = tableQualifiedName(cluster, catalog, db, table)
+        // TODO parse datasource type
+        Some(new AtlasObjectId(HIVE_TABLE_TYPE, "qualifiedName", 
qualifiedName))
+      case _ =>
+        None
     }
   }
 
-  def tableQualifiedName(cluster: String, db: String, table: String): String = 
{
-    s"${db.toLowerCase}.${table.toLowerCase}@$cluster"
+  def tableQualifiedName(cluster: String, catalog: String, db: String, table: 
String): String = {
+    s"${catalog.toLowerCase}.${db.toLowerCase}.${table.toLowerCase}@$cluster"
   }
 
   def columnObjectId(columnName: String): Option[AtlasObjectId] = {
-    val dbTbCol = columnName.split('.')
-    if (dbTbCol.length == 3) {
-      val qualifiedName = columnQualifiedName(cluster, dbTbCol(0), dbTbCol(1), 
dbTbCol(2))
-      // TODO parse datasource type
-      Some(new AtlasObjectId(HIVE_COLUMN_TYPE, "qualifiedName", qualifiedName))
-    } else {
-      None
+    columnName.split('.') match {
+      case Array(catalog, db, table, column) =>

Review Comment:
   ditto



##########
extensions/spark/kyuubi-spark-lineage/src/main/scala/org/apache/kyuubi/plugin/lineage/dispatcher/atlas/AtlasEntityHelper.scala:
##########
@@ -104,33 +104,38 @@ object AtlasEntityHelper {
   }
 
   def tableObjectId(tableName: String): Option[AtlasObjectId] = {
-    val dbTb = tableName.split('.')
-    if (dbTb.length == 2) {
-      val qualifiedName = tableQualifiedName(cluster, dbTb(0), dbTb(1))
-      // TODO parse datasource type
-      Some(new AtlasObjectId(HIVE_TABLE_TYPE, "qualifiedName", qualifiedName))
-    } else {
-      None
+    tableName.split('.') match {
+      case Array(catalog, db, table) =>
+        val qualifiedName = tableQualifiedName(cluster, catalog, db, table)
+        // TODO parse datasource type
+        Some(new AtlasObjectId(HIVE_TABLE_TYPE, "qualifiedName", 
qualifiedName))
+      case _ =>
+        None
     }
   }
 
-  def tableQualifiedName(cluster: String, db: String, table: String): String = 
{
-    s"${db.toLowerCase}.${table.toLowerCase}@$cluster"
+  def tableQualifiedName(cluster: String, catalog: String, db: String, table: 
String): String = {
+    s"${catalog.toLowerCase}.${db.toLowerCase}.${table.toLowerCase}@$cluster"
   }
 
   def columnObjectId(columnName: String): Option[AtlasObjectId] = {
-    val dbTbCol = columnName.split('.')
-    if (dbTbCol.length == 3) {
-      val qualifiedName = columnQualifiedName(cluster, dbTbCol(0), dbTbCol(1), 
dbTbCol(2))
-      // TODO parse datasource type
-      Some(new AtlasObjectId(HIVE_COLUMN_TYPE, "qualifiedName", qualifiedName))
-    } else {
-      None
+    columnName.split('.') match {
+      case Array(catalog, db, table, column) =>
+        val qualifiedName = columnQualifiedName(cluster, catalog, db, table, 
column)
+        // TODO parse datasource type
+        Some(new AtlasObjectId(HIVE_COLUMN_TYPE, "qualifiedName", 
qualifiedName))
+      case _ =>
+        None
     }
   }
 
-  def columnQualifiedName(cluster: String, db: String, table: String, column: 
String): String = {
-    s"${db.toLowerCase}.${table.toLowerCase}.${column.toLowerCase}@$cluster"
+  def columnQualifiedName(
+      cluster: String,
+      catalog: String,
+      db: String,
+      table: String,
+      column: String): String = {
+    
s"${catalog.toLowerCase}.${db.toLowerCase}.${table.toLowerCase}.${column.toLowerCase}@$cluster"

Review Comment:
   ditto



##########
extensions/spark/kyuubi-spark-lineage/src/main/scala/org/apache/kyuubi/plugin/lineage/dispatcher/atlas/AtlasEntityHelper.scala:
##########
@@ -104,33 +104,38 @@ object AtlasEntityHelper {
   }
 
   def tableObjectId(tableName: String): Option[AtlasObjectId] = {
-    val dbTb = tableName.split('.')
-    if (dbTb.length == 2) {
-      val qualifiedName = tableQualifiedName(cluster, dbTb(0), dbTb(1))
-      // TODO parse datasource type
-      Some(new AtlasObjectId(HIVE_TABLE_TYPE, "qualifiedName", qualifiedName))
-    } else {
-      None
+    tableName.split('.') match {
+      case Array(catalog, db, table) =>

Review Comment:
   We should ignore the catalog for Atlas, because the Hive Hook in Atlas also 
does not specify a catalog:
   
   
https://github.com/apache/atlas/blob/b7849aeb78856f2f8e205c5e784cee84409cbc72/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java#L884



-- 
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]

Reply via email to