Checks whether a specified partition exists in a table.
Syntax
boolean partition_exists(string <table_name>, string... <partitions>)
Parameters
-
table_name: STRING. The name of the table to check. To reference a table in another MaxCompute project, use the format<project_name>.<table_name>. If no project name is specified, the current project is used. -
partitions: STRING. The partition key values to look up, specified in the same order as the partition key columns are defined in the table schema. The number of values must match the number of partition key columns exactly.
Return value
Returns a BOOLEAN value: True if the partition exists, False if it does not.
Examples
The following examples use a two-level partitioned table with partition keys ds and hr.
-- Create a partitioned table.
CREATE TABLE foo (id BIGINT) PARTITIONED BY (ds STRING, hr STRING);
-- Add a partition.
ALTER TABLE foo ADD PARTITION (ds='20190101', hr='1');
-- Check whether partition ds='20190101', hr='1' exists. Returns True.
SELECT partition_exists('foo', '20190101', '1');
Related functions
For other built-in functions, see Other functions.
该文章对您有帮助吗?