meel-ayush commented on code in PR #76828: URL: https://github.com/apache/airflow/pull/76828#discussion_r4634673156
########## providers/common/sql/src/airflow/providers/common/sql/utils/sql_validation.py: ########## @@ -0,0 +1,588 @@ +# 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. +from __future__ import annotations + +import re +from collections.abc import Mapping, Sequence +from typing import Any + +from airflow.providers.common.compat.sdk import AirflowOptionalProviderFeatureException + +try: + import sqlglot + from sqlglot import exp + from sqlglot.dialects import Dialects + from sqlglot.errors import ErrorLevel, ParseError +except ImportError: + sqlglot = None # type: ignore[assignment] + exp = None # type: ignore[assignment] + Dialects = None # type: ignore[assignment] + ErrorLevel = None # type: ignore[assignment,misc] + ParseError = None # type: ignore[assignment,misc] + +_KNOWN_SQLGLOT_DIALECTS: frozenset[str] = ( + frozenset(d.value for d in Dialects) if Dialects is not None else frozenset() Review Comment: Done. Raised AirflowOptionalProviderFeatureException directly on ImportError at the top of the module. Dropped all the defensive sqlglot = None, _require_sqlglot(), and fallback type ignores throughout the file. -- 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]
