hainenber commented on code in PR #32310:
URL: https://github.com/apache/superset/pull/32310#discussion_r1961861501


##########
superset/daos/database.py:
##########
@@ -165,7 +168,30 @@ def get_ssh_tunnel(cls, database_id: int) -> SSHTunnel | 
None:
         )
 
         return ssh_tunnel
-
+    
+    @classmethod
+    def is_odps_partitioned_table(cls, database: Database, table_name: str):

Review Comment:
   can you add the function signature here?



##########
superset/databases/api.py:
##########
@@ -1002,15 +1003,16 @@ def table_metadata(self, pk: int) -> FlaskResponse:
             parameters = QualifiedTableSchema().load(request.args)
         except ValidationError as ex:
             raise InvalidPayloadSchemaError(ex) from ex
-
-        table = Table(parameters["name"], parameters["schema"], 
parameters["catalog"])
+        table_name = str(parameters["name"])
+        ispartitioned_table, partition_fields = 
DatabaseDAO.is_odps_partitioned_table(database,table_name)

Review Comment:
   nit: `ispartitioned` is not snake-cased



##########
superset/daos/database.py:
##########
@@ -165,7 +168,30 @@ def get_ssh_tunnel(cls, database_id: int) -> SSHTunnel | 
None:
         )
 
         return ssh_tunnel
-
+    
+    @classmethod
+    def is_odps_partitioned_table(cls, database: Database, table_name: str):
+        if not database:
+            raise ValueError("Database not found")
+        uri = database.sqlalchemy_uri
+        passwd = database.password
+        pattern = re.compile(
+            
r'odps://(?P<username>[^:]+):(?P<password>[^@]+)@(?P<project>[^/]+)/(?:\?endpoint=(?P<endpoint>[^&]+))'

Review Comment:
   the named capture group `password` is unused here. Can be removed?



##########
superset/db_engine_specs/base.py:
##########
@@ -1689,7 +1690,11 @@ def select_star(  # pylint: disable=too-many-arguments
 
         full_table_name = cls.quote_table(table, engine.dialect)
         qry = select(fields).select_from(text(full_table_name))
-
+        if database.backend == 'odps':
+            if partition.ispartitioned_table and partition.partition_column is 
not None and len(partition.partition_column) > 0:

Review Comment:
   the `partition` variable can be `None` here



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