Greenplum 自定义复合类型 数组

简介:

标签

PostgreSQL , Greenplum , composite type array


背景

如果你现在要在Greenplum中创建一个复合类型,是不会自动给你创建对应的数组类型的。(而实际上PostgreSQL 在2007年已经支持了这个功能)

Greenplum需要等到5.0,才能使用上它了。

https://github.com/greenplum-db/gpdb/commit/8954a537ee6199a80c38581fd3cd7ed463abbdea

Support arrays of composite types  
Backport from upstream with this commit:  
  
    commit bc8036f  
    Author: Tom Lane <tgl@sss.pgh.pa.us>  
    Date:   Fri May 11 17:57:14 2007 +0000  
  
        Support arrays of composite types, including the rowtypes of regular tables  
        and views (but not system catalogs, nor sequences or toast tables).  Get rid  
        of the hardwired convention that a type's array type is named exactly "_type",  
        instead using a new column pg_type.typarray to provide the linkage.  (It still  
        will be named "_type", though, except in odd corner cases such as  
        maximum-length type names.)  
  
        Along the way, make tracking of owner and schema dependencies for types more  
        uniform: a type directly created by the user has these dependencies, while a  
        table rowtype or auto-generated array type does not have them, but depends on  
        its parent object instead.  
  
        David Fetter, Andrew Dunstan, Tom Lane  
 master (#1)  5.0.0-alpha.1 5.0.0-alpha.0  
1 parent 5b33bee commit 8954a537ee6199a80c38581fd3cd7ed463abbdea @HaozhouWang HaozhouWang committed on 9 Mar 2016  

https://www.postgresql.org/docs/8.2/static/sql-createtype.html

Array Types

Whenever a user-defined base data type is created, PostgreSQL automatically creates an associated array type,   
whose name consists of the base type's name prepended with an underscore.   
The parser understands this naming convention, and translates requests for columns of type foo[] into requests for type _foo.   
The implicitly-created array type is variable length and uses the built-in input and output functions array_in and array_out.  
  
You might reasonably ask why there is an ELEMENT option, if the system makes the correct array type automatically.   
The only case where it's useful to use ELEMENT is when you are making a fixed-length type that happens to be internally an array of a number of identical things,  
and you want to allow these things to be accessed directly by subscripting, in addition to whatever operations you plan to provide for the type as a whole.   
For example, type name allows its constituent char elements to be accessed this way.   
A 2-D point type could allow its two component numbers to be accessed like point[0] and point[1].   
  
Note that this facility only works for fixed-length types whose internal form is exactly a sequence of identical fixed-length fields.   
A subscriptable variable-length type must have the generalized internal representation used by array_in and array_out. For historical reasons   
(i.e., this is clearly wrong but it's far too late to change it),   
subscripting of fixed-length array types starts from zero, rather than from one as for variable-length arrays.  
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
4天前
|
数据采集 人工智能 安全
|
13天前
|
云安全 监控 安全
|
5天前
|
自然语言处理 API
万相 Wan2.6 全新升级发布!人人都能当导演的时代来了
通义万相2.6全新升级,支持文生图、图生视频、文生视频,打造电影级创作体验。智能分镜、角色扮演、音画同步,让创意一键成片,大众也能轻松制作高质量短视频。
1122 152
|
19天前
|
机器学习/深度学习 人工智能 自然语言处理
Z-Image:冲击体验上限的下一代图像生成模型
通义实验室推出全新文生图模型Z-Image,以6B参数实现“快、稳、轻、准”突破。Turbo版本仅需8步亚秒级生成,支持16GB显存设备,中英双语理解与文字渲染尤为出色,真实感和美学表现媲美国际顶尖模型,被誉为“最值得关注的开源生图模型之一”。
1793 9
|
10天前
|
人工智能 自然语言处理 API
一句话生成拓扑图!AI+Draw.io 封神开源组合,工具让你的效率爆炸
一句话生成拓扑图!next-ai-draw-io 结合 AI 与 Draw.io,通过自然语言秒出架构图,支持私有部署、免费大模型接口,彻底解放生产力,绘图效率直接爆炸。
719 152
|
7天前
|
SQL 自然语言处理 调度
Agent Skills 的一次工程实践
**本文采用 Agent Skills 实现整体智能体**,开发框架采用 AgentScope,模型使用 **qwen3-max**。Agent Skills 是 Anthropic 新推出的一种有别于mcp server的一种开发方式,用于为 AI **引入可共享的专业技能**。经验封装到**可发现、可复用的能力单元**中,每个技能以文件夹形式存在,包含特定任务的指导性说明(SKILL.md 文件)、脚本代码和资源等 。大模型可以根据需要动态加载这些技能,从而扩展自身的功能。目前不少国内外的一些框架也开始支持此种的开发方式,详细介绍如下。
493 5
|
12天前
|
人工智能 安全 前端开发
AgentScope Java v1.0 发布,让 Java 开发者轻松构建企业级 Agentic 应用
AgentScope 重磅发布 Java 版本,拥抱企业开发主流技术栈。
671 14