eschutho commented on a change in pull request #13448: URL: https://github.com/apache/superset/pull/13448#discussion_r587962551
########## File path: superset/utils/data.py ########## @@ -0,0 +1,163 @@ +# 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. +import random +import string +import sys +from datetime import date, datetime, time, timedelta +from typing import Any, Callable, cast, Dict, List, Optional + +import sqlalchemy.sql.sqltypes +from sqlalchemy import Column, inspect, MetaData, Table +from sqlalchemy.sql.visitors import VisitableType +from typing_extensions import TypedDict + +ColumnInfo = TypedDict( + "ColumnInfo", + { + "name": str, + "type": VisitableType, + "nullable": bool, + "default": Optional[Any], + "autoincrement": str, + "primary_key": int, + }, +) + + +example_column = { + "name": "id", + "type": sqlalchemy.sql.sqltypes.INTEGER(), + "nullable": False, + "default": None, + "autoincrement": "auto", + "primary_key": 1, +} + + +MINIMUM_DATE = date(1900, 1, 1) +MAXIMUM_DATE = date.today() +days_range = (MAXIMUM_DATE - MINIMUM_DATE).days + + +def get_type_generator(sqltype: sqlalchemy.sql.sqltypes) -> Callable[[], Any]: + if isinstance(sqltype, sqlalchemy.sql.sqltypes.INTEGER): + return lambda: random.randrange(2147483647) + + if isinstance(sqltype, sqlalchemy.sql.sqltypes.BIGINT): + return lambda: random.randrange(sys.maxsize) + + if isinstance(sqltype, sqlalchemy.sql.sqltypes.VARCHAR): + length = random.randrange(sqltype.length or 255) + return lambda: "".join(random.choices(string.printable, k=length)) + + if isinstance(sqltype, sqlalchemy.sql.sqltypes.TEXT): + length = random.randrange(65535) Review comment: I tried running this locally, and it pretty much locks up sql lab for me. A range of 2k characters still feels good. Do you think this large number is indicative of datasets that we should expect to see? The ScrollSync doesn't help here either because the col width is over 97k pixels wide. :op ---------------------------------------------------------------- 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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
