You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/08 02:22:15 UTC

[GitHub] [superset] fangxuyi opened a new pull request #17973: feat: initial setup for sybase

fangxuyi opened a new pull request #17973:
URL: https://github.com/apache/superset/pull/17973


   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   add connectors for sybase
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a change in pull request #17973: feat: initial setup for sybase

Posted by GitBox <gi...@apache.org>.
villebro commented on a change in pull request #17973:
URL: https://github.com/apache/superset/pull/17973#discussion_r780946274



##########
File path: setup.py
##########
@@ -157,6 +157,7 @@ def get_git_sha() -> str:
         "snowflake": [
             "snowflake-sqlalchemy==1.2.4"
         ],  # PINNED! 1.2.5 introduced breaking changes requiring sqlalchemy>=1.4.0
+        "sybase": ["sqlalchemy-sybase>=1.0.6"],

Review comment:
       nit: Let's restrict this to the current major version:
   ```suggestion
           "sybase": ["sqlalchemy-sybase>=1.0.6, <2"],
   ```

##########
File path: superset/db_engine_specs/sybase.py
##########
@@ -0,0 +1,64 @@
+# 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 datetime import datetime
+from typing import Any, Dict, Optional, TYPE_CHECKING
+
+from superset.db_engine_specs.base import BaseEngineSpec
+from superset.utils import core as utils
+
+if TYPE_CHECKING:
+    from superset.connectors.sqla.models import TableColumn
+
+
+class SybaseEngineSpec(BaseEngineSpec):
+    engine = "sybase"
+    engine_name = "Sybase"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "DATEPART(SECOND, {col})",
+        "PT1M": "DATEPART(MINUTE, {col})",
+        "PT1H": "DATEPART(HOUR, {col})",
+        "P1D": "DATEPART(DAY, {col})",
+        "P1W": "DATEPART(WEEK, {col})",
+        "P1M": "DATEPART(MONTH, {col})",
+        "P3M": "DATEPART(QUARTER, {col})",
+        "P1Y": "DATEPART(YEAR, {col})",
+    }
+
+    @classmethod
+    def epoch_ms_to_dttm(cls) -> str:
+        return "{col}"
+
+    @classmethod
+    def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+        print(cls)
+        tt = target_type.upper()
+        if tt == utils.TemporalType.DATE:
+            return f"DATE '{dttm.date().isoformat()}'"
+        if tt == utils.TemporalType.DATETIME:
+            dttm_formatted = dttm.isoformat(sep=" ", timespec="microseconds")
+            return f"""DATETIME '{dttm_formatted}'"""
+        if tt == utils.TemporalType.TIMESTAMP:
+            dttm_formatted = dttm.isoformat(timespec="microseconds")
+            return f"""TIMESTAMP '{dttm_formatted}'"""
+        return None
+
+    @classmethod
+    def alter_new_orm_column(cls, orm_col: "TableColumn") -> None:
+        if orm_col.type == "TIMESTAMP":
+            orm_col.python_date_format = "epoch_ms"

Review comment:
       Is this really required? This is only needed if the database returns timestamps as numeric values, in this case millisecond epochs. So far I've only seen this being needed in the CrateDB spec.




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] geido commented on a change in pull request #17973: feat: initial setup for sybase

Posted by GitBox <gi...@apache.org>.
geido commented on a change in pull request #17973:
URL: https://github.com/apache/superset/pull/17973#discussion_r781287933



##########
File path: superset/db_engine_specs/sybase.py
##########
@@ -0,0 +1,64 @@
+# 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 datetime import datetime
+from typing import Any, Dict, Optional, TYPE_CHECKING
+
+from superset.db_engine_specs.base import BaseEngineSpec
+from superset.utils import core as utils
+
+if TYPE_CHECKING:
+    from superset.connectors.sqla.models import TableColumn
+
+
+class SybaseEngineSpec(BaseEngineSpec):
+    engine = "sybase"
+    engine_name = "Sybase"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "DATEPART(SECOND, {col})",
+        "PT1M": "DATEPART(MINUTE, {col})",
+        "PT1H": "DATEPART(HOUR, {col})",
+        "P1D": "DATEPART(DAY, {col})",
+        "P1W": "DATEPART(WEEK, {col})",
+        "P1M": "DATEPART(MONTH, {col})",
+        "P3M": "DATEPART(QUARTER, {col})",
+        "P1Y": "DATEPART(YEAR, {col})",
+    }
+
+    @classmethod
+    def epoch_ms_to_dttm(cls) -> str:
+        return "{col}"
+
+    @classmethod
+    def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+        print(cls)

Review comment:
       ```suggestion
   ```




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org