mccushjack commented on a change in pull request #15930:
URL: https://github.com/apache/superset/pull/15930#discussion_r748574026
##########
File path: superset/db_engine_specs/teradata.py
##########
@@ -14,13 +14,223 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+from dataclasses import dataclass # pylint: disable=wrong-import-order
+from enum import Enum
+from typing import List, Optional, Set
+from urllib import parse
+
+import sqlparse
+from sqlparse.sql import (
+ Identifier,
+ IdentifierList,
+ Parenthesis,
+ remove_quotes,
+ Token,
+ TokenList,
+)
+from sqlparse.tokens import Keyword, Name, Punctuation, String, Whitespace
+from sqlparse.utils import imt
+
from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
+from superset.sql_parse import Table
+
+PRECEDES_TABLE_NAME = {"FROM", "JOIN", "DESCRIBE", "WITH", "LEFT JOIN", "RIGHT
JOIN"}
+CTE_PREFIX = "CTE__"
+
+
+def _extract_limit_from_query_td(statement: TokenList) -> Optional[int]:
+ td_limit_keywork = set(["TOP", "SAMPLE"])
+ str_statement = str(statement)
+ str_statement = str_statement.replace("\n", " ").replace("\r", "")
+ token = str(str_statement).rstrip().split(" ")
+ token = list(filter(None, token))
+ limit = None
+
+ for i in range(len(token)):
+ if any(limitword in token[i].upper() for limitword in
td_limit_keywork):
+ if len(token) - 1 > i:
Review comment:
@betodealmeida -- I fixed the error in unit tests and made the other
idiomatic changes you requested.
--
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]