Based on the official PostgreSQL functions, MaxCompute Lightning supports the query syntax and built-in functions, such as MAX_PT.

Query syntax

The MaxCompute Lightning query engine is based on PostgreSQL 8.2. MaxCompute Lightning only supports SELECT queries for existing MaxCompute tables. For more information about the query syntax, visit PostgreSQL.

Function

MAX_PT

Syntax

max_pt(table_full_name)

Description

This function is used to return the name of and values in the level-1 partition that has the maximum partitioning column value and contains data files in a partitioned table. The returned values are sorted in alphabetic order.

Parameter

table_full_name: the table name, which must be of the STRING type. The table name must contain the project name, such as prj.src. You must have read permissions on this table.

Return value

The name of and values in the level-1 partition that has the maximum partitioning column value are returned.

Example

Assume that the tbl table is a partitioned table. The partitions in the table are as follows and contain data files:

pt ='20120901'
pt ='20120902'

In this example, 20120902 is returned. The MaxCompute SQL statement reads the data in the pt='20120902' partition.

select * from tbl where pt=max_pt('myproject.tbl');