You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/08/06 20:08:12 UTC

[GitHub] [incubator-superset] john-bodley commented on a change in pull request #7993: [Jinja] Make Presto template functions backwards compatible

john-bodley commented on a change in pull request #7993: [Jinja] Make Presto template functions backwards compatible
URL: https://github.com/apache/incubator-superset/pull/7993#discussion_r311251372
 
 

 ##########
 File path: superset/jinja_context.py
 ##########
 @@ -240,7 +240,39 @@ def _schema_table(
             schema, table_name = table_name.split(".")
         return table_name, schema
 
-    def latest_partition(self, table_name: str):
+    def latest_partition(self, table_name: str) -> str:
+        """
+        Supports the backwards compatible Jinja template API from before
+        https://github.com/apache/incubator-superset/pull/7782. Returns the first
+        (or only) value in the array of all latest partitions for the given table name.
+
+        :param table_name: table name in the format `schema.table`
+        :return: the first (or only) value in the latest partition array
+        """
+
+        return self._first_latest_partition(table_name)
+
+    def _first_latest_partition(self, table_name: str) -> str:
 
 Review comment:
   Do we need this function as it's only called once from above. Additionally the logic looks similar to `latest_partitions` and thus it seems line #253 could simply be, 
   
   ```
   return self.latest_partitions(table_name)[0]
   ``` 
   
   Note for both `latest_partition` and `latest_partitions` an `IndexError` could be thrown and thus it's probably prudent to add mention in the docstring, i.e., 
   
   ```
   :param table_name: table name in the format `schema.table`
   :return: the first (or only) value in the latest partition array
   :raises IndexError: If no partition exists
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org