sadpandajoe commented on code in PR #40679: URL: https://github.com/apache/superset/pull/40679#discussion_r3872710738
########## examples/asset_metadata_translation/model.py: ########## @@ -0,0 +1,68 @@ +# 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. +"""Reference table for storing asset-metadata translations. + +NOT part of Superset core -- see this directory's README. A production version +would live in an extension with its own Alembic migration; here we keep a single +declarative model and a helper to create the table on demand. +""" + +from __future__ import annotations + +from sqlalchemy import Column, Integer, String, Text, UniqueConstraint +from sqlalchemy.orm import declarative_base + +Base = declarative_base() + + +class AssetTranslation(Base): # type: ignore[valid-type, misc] + """A single translation of one asset field into one language. + + Keyed on the source text plus model/field context so identical strings in + different fields can be translated independently. ``default_text`` is the + canonical value stored on the asset (e.g. ``Slice.slice_name``). + """ + + __tablename__ = "asset_translations" + + id = Column(Integer, primary_key=True) + model_name = Column(String(64), nullable=False) + field_name = Column(String(64), nullable=False) + default_text = Column(Text, nullable=False) Review Comment: This column participates in `uq_asset_translation`, but MySQL/MariaDB cannot create an index over an unbounded `TEXT` column without a prefix length. Since Superset supports those metadata databases, following this example's create-table flow fails there before the hook can run. Could `default_text` use an indexable bounded representation (or otherwise avoid indexing the raw `TEXT` value)? -- 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]
