nizhikov commented on a change in pull request #5598: IGNITE-10314 Spark 
dataframe will get wrong schema if user executes add/drop column DDL
URL: https://github.com/apache/ignite/pull/5598#discussion_r249274203
 
 

 ##########
 File path: 
modules/spark/src/main/scala/org/apache/ignite/spark/impl/package.scala
 ##########
 @@ -117,24 +113,39 @@ package object impl {
       * @param ignite Ignite instance.
       * @param tabName Table name.
       * @param schemaName Optional schema name.
-      * @tparam K Key class.
-      * @tparam V Value class.
-      * @return CacheConfiguration and QueryEntity for a given table.
+      * @return GridQueryTypeDescriptor for a given table.
       */
-    def sqlTableInfo[K, V](ignite: Ignite, tabName: String,
-        schemaName: Option[String]): Option[(CacheConfiguration[K, V], 
QueryEntity)] =
-        cachesForSchema[K,V](ignite, schemaName)
-            .map(ccfg ⇒ 
ccfg.getQueryEntities.find(_.getTableName.equalsIgnoreCase(tabName)).map(qe ⇒ 
(ccfg, qe)))
-            .find(_.isDefined)
-            .flatten
+    def sqlTableInfo(ignite: Ignite, tabName: String, schemaName: 
Option[String]): Option[GridQueryTypeDescriptor] =
+        ignite.asInstanceOf[IgniteEx].context.cache.publicCacheNames.flatMap(
+            cacheName => 
ignite.asInstanceOf[IgniteEx].context.query.types(cacheName))
+            .find(table => table.tableName.equalsIgnoreCase(tabName) && 
isValidSchema(table, schemaName))
+
+    /**
+      * @param table GridQueryTypeDescriptor for a given table.
+      * @param schemaName Optional schema name.
+      * @return `True` if schema is valid.
+      */
+    def isValidSchema(table: GridQueryTypeDescriptor, schemaName: 
Option[String]): Boolean =
 
 Review comment:
   Let's use a bit different formatting?
   
   ```
       def isSameSchema(table: GridQueryTypeDescriptor, schemaName: 
Option[String]): Boolean =
           schemaName match {
               case Some(schema) => 
                   schema.equalsIgnoreCase(table.schemaName) || 
schema.equals(DEFAULT_DATABASE)
               case None => 
                   true
           }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to