编译的时候需要在superset/superset/db_engine_specs以下路径增加一个 odps.py的文件

# 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, List, Optional, Tuple
from superset.db_engine_specs.base import BaseEngineSpec
from superset.utils import core as utils
class ODPSEngineSpec(BaseEngineSpec):
    engine = "odps"
    engine_name = "MaxCompute"
    _time_grain_expressions = {
        None: "{col}",
        "PT1S": "CAST({col} as DATETIME)",
        "PT1M": "DATETRUNC(CAST({col} as DATETIME),'MI')",
        "PT1H": "DATETRUNC(CAST({col} as DATETIME),'HH')",
        "P1D": "DATE({col})",
        "P1W": "DATETRUNC(CAST({col} as DATETIME),'w')",
        "P1M": "DATETRUNC(CAST({col} as DATETIME),'mon')",
        "P3M": "DATETRUNC(CAST({col} as DATETIME),'q')",
        "P1Y": "DATETRUNC(CAST({col} as DATETIME),'year')",
    }
    @classmethod
    def convert_dttm(
        cls, target_type: str, dttm: datetime, db_extra: Optional[Dict[str, Any]] = None
    ) -> Optional[str]:
        tt = target_type.upper()
        if tt == utils.TemporalType.DATE:
            return f"TO_DATE('{dttm.date().isoformat()}', 'yyyy-mm-dd')"
        if tt == utils.TemporalType.DATETIME:
            datetime_formatted = dttm.isoformat(sep=" ", timespec="microseconds")
            return f"""TO_DATE('{datetime_formatted}', 'yyyy-mm-dd hh:mi:ss.ff3')"""
        return None
    @classmethod
    def epoch_to_dttm(cls) -> str:
        return "from_unixtime({col})"

最新文章

  1. Win7 登入提示临时漫游档案
  2. [译]rabbitmq 2.2 Building from the bottom: queues
  3. IBatis.Net 批量插入数据
  4. gulp 使用mailgun服务器发送邮件
  5. 第二百七十二、三天 how can I 坚持
  6. Python基础教程之List对象 转
  7. Swift Swift语言Storyboard教程:第二部
  8. 执行 npm run update-webdriver 提示文件不能获取错误
  9. vue+vue-router+vuex实战
  10. JMeter进行一次简单的压力测试
  11. Django中URL有关
  12. Nginx 学习笔记(四)nginx-module-vts模块
  13. 动态规划之132 Palindrome Partitioning II
  14. Spring设置动态定时任务
  15. MVC 学习(一)Linq to Entities 简单Demo
  16. jquery 鼠标事件汇总
  17. panel内嵌程序窗体
  18. php 传变量到 js 文件
  19. lua调用c++函数返回值作用
  20. jvm系列 (一) ---jvm内存区域与溢出

热门文章

  1. Vue框架整理:computed计算属性设置与缓存
  2. PostgreSQL事务隔离级别
  3. ImGui窗口标题栏的高度
  4. DataTransfer.setDragImage()自定义拖拽图像遇到的坑
  5. ImportError: cannot import name 'six' from 'django.utils'的解决办法
  6. 客户端发送信息给服务器以及服务器接收客户端发来的信息(socket)
  7. java字段值为null,不返回该字段
  8. 2022-05-06内部群每日三题-清辉PMP
  9. The table‘xxxx’is full
  10. java之路总结