All Products
Search
Document Center

MaxCompute:PARTITION_EXISTS

Last Updated:Jul 24, 2023

Checks whether a specified partition exists in a table.

Syntax

boolean partition_exists(string <table_name>, string... <partitions>)

Parameters

  • table_name: required. The table name, which is of the STRING type. You can specify a project name in the table name. The name of a table can be my_proj.my_table. If you do not specify a project name, the current project name is used.

  • partitions: required. The names of partitions, which are of the STRING type. In this parameter, you must specify the values of partition key columns in a table based on the sequence of the columns. The number of values must be the same as the number of partition key columns.

Return value

A value of the BOOLEAN type is returned. If the specified partition exists, True is returned. Otherwise, False is returned.

Examples

-- Create a partitioned table named foo. 
create table foo (id bigint) partitioned by (ds string, hr string);
-- Add partitions to the partitioned table named foo. 
alter table foo add partition (ds='20190101', hr='1');
-- Check whether partitions 20190101 and 1 exist. True is returned. 
select partition_exists('foo', '20190101', '1');

Related functions

For more information, see Other functions.