korbit-ai[bot] commented on code in PR #32680: URL: https://github.com/apache/superset/pull/32680#discussion_r1996071402
########## superset/migrations/versions/2025-03-03_20-52_94e7a3499973_add_folder_table.py: ########## @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Add folder table Review Comment: ### Misleading migration name <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The migration name is misleading as it adds a column to an existing table rather than creating a new table. ###### Why this matters This could cause confusion during code maintenance and make it harder to track schema changes accurately. ###### Suggested change ∙ *Feature Preview* Change the migration name to accurately reflect the change: ```python """Add folders column to tables table""" ``` </details> <sub> [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/550327aa-e8ed-4768-85a9-aedcd6c74889?suggestedFixEnabled=true) 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:24bfe66e-eed4-44e4-88f0-2c367dd6b949 --> ########## superset/migrations/versions/2025-03-03_20-52_94e7a3499973_add_folder_table.py: ########## @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Add folder table + +Revision ID: 94e7a3499973 +Revises: 74ad1125881c +Create Date: 2025-03-03 20:52:24.585143 + +""" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.types import JSON + +# revision identifiers, used by Alembic. +revision = "94e7a3499973" +down_revision = "74ad1125881c" + + +def upgrade(): + op.add_column( + "tables", + sa.Column("folders", JSON, nullable=True), + ) Review Comment: ### Denormalized Database Design Using JSON Column <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? Using a JSON column type to store folder data suggests a denormalized design that could make querying, indexing, and maintaining data integrity more difficult. ###### Why this matters JSON columns reduce data consistency, make it harder to enforce referential integrity, complicate querying, and can impact performance. A normalized design with a separate folders table would be more maintainable. ###### Suggested change ∙ *Feature Preview* Create a separate `folders` table with proper relationships: ```python def upgrade(): op.create_table( 'folders', sa.Column('id', sa.Integer(), primary_key=True), sa.Column('name', sa.String(length=250), nullable=False), sa.Column('table_id', sa.Integer(), sa.ForeignKey('tables.id')) ) ``` </details> <sub> [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/0b3e2d74-5dc5-4d90-9bad-991551958eec?suggestedFixEnabled=true) 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:240361d0-00b0-4596-9098-4e32732dcc6a --> ########## superset/migrations/versions/2025-03-03_20-52_94e7a3499973_add_folder_table.py: ########## @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Add folder table + +Revision ID: 94e7a3499973 +Revises: 74ad1125881c +Create Date: 2025-03-03 20:52:24.585143 + +""" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.types import JSON + +# revision identifiers, used by Alembic. +revision = "94e7a3499973" +down_revision = "74ad1125881c" + + +def upgrade(): + op.add_column( + "tables", + sa.Column("folders", JSON, nullable=True), Review Comment: ### Missing JSON default value <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? Using SQLAlchemy's JSON type without specifying a default value could lead to inconsistent behavior across different database backends. ###### Why this matters Different databases handle NULL JSON values differently. Some might store NULL, others empty object/array, leading to potential application logic issues. ###### Suggested change ∙ *Feature Preview* Add a default value (empty object) to ensure consistent behavior across databases: ```python sa.Column("folders", JSON, nullable=True, server_default=sa.text("'{}'::jsonb")) ``` </details> <sub> [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/371f168e-9698-4eb7-a736-15c3ddbeeca3?suggestedFixEnabled=true) 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:c5c1e412-26db-46b9-b688-bc15faeb4a39 --> ########## superset/migrations/versions/2025-03-03_20-52_94e7a3499973_add_folder_table.py: ########## @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""Add folder table + +Revision ID: 94e7a3499973 +Revises: 74ad1125881c +Create Date: 2025-03-03 20:52:24.585143 + +""" Review Comment: ### Migration description missing column details <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The migration docstring lacks information about the purpose and structure of the new 'folders' column being added. ###### Why this matters Future developers will not understand the intended use of the JSON column or its schema, making it harder to maintain or debug issues. ###### Suggested change ∙ *Feature Preview* """Add folder table Revision ID: 94e7a3499973 Revises: 74ad1125881c Create Date: 2025-03-03 20:52:24.585143 Adds a JSON column 'folders' to the tables table to store folder hierarchy and metadata for organizing tables. The column is nullable to maintain backward compatibility. """ </details> <sub> [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/39041a7f-c13b-4be1-a172-9e349e2ba14f?suggestedFixEnabled=true) 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:45d721c7-32d9-47ca-bdb4-2b98b7df158c --> -- 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]
