编译的时候需要在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})"

superset2.0.0 支持MaxCompute 时间颗粒的更多相关文章

  1. FineUI(专业版)v3.0.0 发布,手机、平板和桌面全支持!

    FineUI(专业版)v3.0.0 已经正式发布,全面支持手机.平板和桌面!       自 2008 年 4 月发布第一个版本,我们持续更新了 126 个版本,拥有 16000 多位注册用户,130 ...

  2. Centos7.4下安装Jumpserver 1.0.0(支持windows组件)

    0)系统环境CentOS 7.4 IP: 192.168.100.10 [root@jumpserver-server ~]# cat /etc/redhat-release CentOS Linux ...

  3. Centos7.3下安装Jumpserver 1.0.0(支持windows组件)

    Jumpserver最新版本支持windows组件,废话不多介绍了,下面直接介绍下部署过程: 0)系统环境 CentOS 7.3 IP: 192.168.10.210 [root@jumpserver ...

  4. 基于Dapper的开源Lambda扩展LnskyDB 2.0已支持多表查询

    LnskyDB LnskyDB是基于Dapper的Lambda扩展,支持按时间分库分表,也可以自定义分库分表方法.而且可以T4生成实体类免去手写实体类的烦恼. 文档地址: https://lining ...

  5. Fundebug前端异常监控插件更新至2.0.0,全面支持TypeScript

    摘要: 是时候支持TS了! Fundebug前端异常监控服务 Fundebug提供专业的前端异常监控服务,我们的插件可以提供全方位的异常监控,可以帮助开发者第一时间定位各种前端异常,包括但不限于Jav ...

  6. Fundebug后端Node.js插件更新至0.2.0,支持监控Express慢请求

    摘要: 性能问题也是BUG,也需要监控. Fundebug后端Node.js异常监控服务 Fundebug是专业的应用异常监控平台,我们Node.js插件fundebug-nodejs可以提供全方位的 ...

  7. centos7.6环境zabbix3.2源码编译安装版升级到zabbix4.0长期支持版

    zabbix3.2源码编译安装版升级到zabbix4.0长期支持版 项目需求: .2版本不再支持,想升级成4.0的长期支持版 环境介绍: zabbix服务端是编译安装的,数据库和web在一台机器上 整 ...

  8. Spring Cloud 2021.0.0 正式发布,第一个支持Spring Boot 2.6的版本!

    美国时间12月2日,Spring Cloud 正式发布了第一个支持 Spring Boot 2.6 的版本,版本号为:2021.0.0,codename 为 Jubilee. 在了解具体更新内容之前, ...

  9. AgileConfig 1.6.0 发布 - 支持服务注册与发现

    大家好,好久没有输出博文了,一是因为比较忙,另外一个原因是最近主要的精力是在给 AgileConfig 添加一个新的功能:服务注册与发现. 先说说为什么会添加这个功能.我自己的项目是用 Consul ...

  10. CoreWCF 1.0.0 发布,微软正式支持WCF

    2022年4月28日,我们达到了一个重要的里程碑,并发布了CoreWCF的1.0.0版本.对Matt Connew (微软WCF团队成员)来说,这是5年前即 2017年1月开始的漫长旅程的结束.Mat ...

随机推荐

  1. AcWing 141 周期

    题目:https://www.acwing.com/problem/content/143/ 一个字符串的前缀是从第一个字符开始的连续若干个字符,例如"abaab"共有5个前缀,分 ...

  2. Postgres14.4(Docker安装)

    Postgres14.4(Docker安装) 一,Docker拉取镜像 docker pull postgres:14.4 #检查镜像是否拉取成功 docker images | grep postg ...

  3. Vue框架整理:computed计算属性设置与缓存

    简单的一些小计算可以直接用模板内的表达式计算,比较复杂一点的就建议使用"计算属性来运算了",也方便后期的维护:vue所有的计算属性都以函数的形式写在Vue实例内的computed里 ...

  4. 3.基于Label studio的训练数据标注指南:文本分类任务

    文本分类任务Label Studio使用指南 1.基于Label studio的训练数据标注指南:信息抽取(实体关系抽取).文本分类等 2.基于Label studio的训练数据标注指南:(智能文档) ...

  5. SQL常用命令使用方法

    (1) 数据记录筛选: sql="select * from 数据表 where 字段名=字段值 order by 字段名 [desc]" sql="select * f ...

  6. Js 实现登录框可拖动

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 访问不通github的解决办法

    访问不通github, 在hosts文件中手动加下域名IP 在hosts里添加github的ip 140.82.113.3 github.com #不要.199.232.5.194 github.gl ...

  8. No.2.4

    Flex布局 主轴方向:(使用flex-direction改变元素排列方向) 思考:Flex布局模型中,弹性盒子默认沿着哪个方向排列? 水平方向 思考:如何实现内容垂直排列? 修改主轴的方向 主轴默认 ...

  9. VideoMAE Masked Autoencoders are Data-Efficient Learners for Self-Supervised Video Pre-Training概述

    0.前言 相关资料: arxiv github 论文解读(知乎,CSDN) 论文基本信息: 领域:视频自监督表示学习 发表时间:NeurIPS 2022(2022.3.23) 1.针对的问题 视频存在 ...

  10. accessservice对于难定位的view如何定位

    private static int tabcount = -1; private static StringBuilder sb; public static void printPacketInf ...