Skip to content

Commit 80c7b69

Browse files
authored
Merge branch 'prestodb:master' into xiao2602241updatepath
2 parents d060ccd + 0d6a4d5 commit 80c7b69

File tree

72 files changed

+2834
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2834
-20
lines changed

presto-analyzer/src/main/java/com/facebook/presto/sql/analyzer/utils/StatementUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.facebook.presto.sql.tree.CreateSchema;
2929
import com.facebook.presto.sql.tree.CreateTable;
3030
import com.facebook.presto.sql.tree.CreateTableAsSelect;
31+
import com.facebook.presto.sql.tree.CreateTag;
3132
import com.facebook.presto.sql.tree.CreateType;
3233
import com.facebook.presto.sql.tree.CreateView;
3334
import com.facebook.presto.sql.tree.Deallocate;
@@ -133,6 +134,7 @@ private StatementUtils() {}
133134
builder.put(AddColumn.class, QueryType.DATA_DEFINITION);
134135
builder.put(CreateTable.class, QueryType.DATA_DEFINITION);
135136
builder.put(CreateBranch.class, QueryType.DATA_DEFINITION);
137+
builder.put(CreateTag.class, QueryType.DATA_DEFINITION);
136138
builder.put(RenameTable.class, QueryType.DATA_DEFINITION);
137139
builder.put(RenameColumn.class, QueryType.DATA_DEFINITION);
138140
builder.put(DropColumn.class, QueryType.DATA_DEFINITION);

presto-docs/src/main/sphinx/connector/hive.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,18 @@ Property Name Description
164164
absolutely necessary to access HDFS.
165165
Example: ``/etc/hdfs-site.xml``
166166

167-
``hive.storage-format`` The default file format used when creating new tables. ``ORC``
168-
169-
``hive.compression-codec`` The compression codec to use when writing files. ``GZIP``
167+
``hive.storage-format`` The default file format used when creating new tables. The ``ORC``
168+
available values are ``ORC``, ``PARQUET``, ``AVRO``,
169+
``RCBINARY``, ``RCTEXT``, ``SEQUENCEFILE``, ``JSON``,
170+
and ``TEXTFILE``.
171+
172+
``hive.compression-codec`` The compression codec to use when writing files. The ``GZIP``
173+
available values are ``NONE``, ``SNAPPY``, ``GZIP``,
174+
``LZ4``, and ``ZSTD``.
175+
176+
Note: ``LZ4`` is only available when
177+
``hive.storage-format=ORC``. ``ZSTD`` is available
178+
for both ``ORC`` and ``PARQUET`` formats.
170179

171180
``hive.force-local-scheduling`` Force splits to be scheduled on the same node as the Hadoop ``false``
172181
DataNode process serving the split data. This is useful for

presto-docs/src/main/sphinx/connector/iceberg.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,22 @@ Alter table operations are supported in the Iceberg connector::
16211621

16221622
ALTER TABLE iceberg.default.mytable CREATE OR REPLACE BRANCH 'audit-branch-time' FOR SYSTEM_TIME AS OF TIMESTAMP '2026-01-02 17:30:35.247 Asia/Kolkata';
16231623

1624+
ALTER TABLE iceberg.default.mytable CREATE TAG 'audit-tag';
1625+
1626+
ALTER TABLE iceberg.default.mytable CREATE TAG IF NOT EXISTS 'audit-tag';
1627+
1628+
ALTER TABLE iceberg.default.mytable CREATE OR REPLACE TAG 'audit-tag';
1629+
1630+
ALTER TABLE iceberg.default.mytable CREATE TAG 'audit-tag-system' FOR SYSTEM_VERSION AS OF 4176642711908913940;
1631+
1632+
ALTER TABLE iceberg.default.mytable CREATE TAG IF NOT EXISTS 'audit-tag-system' FOR SYSTEM_VERSION AS OF 4176642711908913940;
1633+
1634+
ALTER TABLE iceberg.default.mytable CREATE TAG 'audit-tag-retain' FOR SYSTEM_VERSION AS OF 4176642711908913940 RETAIN 7 DAYS;
1635+
1636+
ALTER TABLE iceberg.default.mytable CREATE TAG 'audit-tag-snap-retain' FOR SYSTEM_VERSION AS OF 4176642711908913940 RETAIN 7 DAYS WITH SNAPSHOT RETENTION 2 SNAPSHOTS 2 DAYS;
1637+
1638+
ALTER TABLE iceberg.default.mytable CREATE OR REPLACE TAG 'audit-tag-time' FOR SYSTEM_TIME AS OF TIMESTAMP '2026-01-02 17:30:35.247 Asia/Kolkata';
1639+
16241640
To add a new column as a partition column, identify the transform functions for the column.
16251641
The table is partitioned by the transformed value of the column::
16261642

presto-docs/src/main/sphinx/presto-cpp.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Note: Presto C++ is in active development. See :doc:`Limitations </presto_cpp/li
99

1010
presto_cpp/installation
1111
presto_cpp/features
12+
presto_cpp/functions
1213
presto_cpp/sidecar
1314
presto_cpp/limitations
1415
presto_cpp/plugin
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
********************
2+
Presto C++ Functions
3+
********************
4+
5+
.. toctree::
6+
:maxdepth: 1
7+
8+
functions/sketch.rst
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
================
2+
Sketch Functions
3+
================
4+
5+
Sketches are data structures that can approximately answer particular questions
6+
about a dataset when full accuracy is not required. Approximate answers are
7+
often faster and more efficient to compute than functions which result in full
8+
accuracy.
9+
10+
Presto C++ provides support for computing some sketches available in the `Apache
11+
DataSketches`_ library.
12+
13+
Theta Sketches
14+
--------------
15+
16+
Theta sketches enable distinct value counting on datasets and also provide the
17+
ability to perform set operations. For more information on Theta sketches,
18+
please see the Apache DataSketches `Theta sketch documentation`_.
19+
20+
.. function:: sketch_theta(x) -> varbinary
21+
22+
Computes a theta sketch from an input dataset. The output from
23+
this function can be used as an input to any of the other ``sketch_theta_*``
24+
family of functions.
25+
26+
.. function:: sketch_theta_estimate(sketch) -> double
27+
28+
Returns the estimate of distinct values from the input sketch.
29+
30+
.. function:: sketch_theta_summary(sketch) -> row(estimate double, theta double, upper_bound_std double, lower_bound_std double, retained_entries int)
31+
32+
Returns a summary of the input sketch which includes the distinct values
33+
estimate alongside other useful information such as the sketch theta
34+
parameter, current error bounds corresponding to 1 standard deviation, and
35+
the number of retained entries in the sketch.
36+
37+
.. _Apache DataSketches: https://datasketches.apache.org/
38+
.. _Theta sketch documentation: https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework

presto-docs/src/main/sphinx/sql/alter-table.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Synopsis
2222
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] BRANCH [ IF NOT EXISTS ] branch_name FOR SYSTEM_TIME AS OF timestamp
2323
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] BRANCH [ IF NOT EXISTS ] branch_name FOR SYSTEM_VERSION AS OF version RETAIN retention_period
2424
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] BRANCH [ IF NOT EXISTS ] branch_name FOR SYSTEM_VERSION AS OF version RETAIN retention_period WITH SNAPSHOT RETENTION min_snapshots SNAPSHOTS min_retention_period
25+
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] tag_name
26+
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] tag_name FOR SYSTEM_VERSION AS OF version
27+
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] tag_name FOR SYSTEM_TIME AS OF timestamp
28+
ALTER TABLE [ IF EXISTS ] name CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] tag_name FOR SYSTEM_VERSION AS OF version RETAIN retention_period
2529
2630
Description
2731
-----------
@@ -40,6 +44,12 @@ For ``CREATE BRANCH`` statements:
4044
* The optional ``IF NOT EXISTS`` clause causes the error to be suppressed if the branch already exists.
4145
* ``OR REPLACE`` and ``IF NOT EXISTS`` cannot be specified together.
4246

47+
For ``CREATE TAG`` statements:
48+
49+
* The optional ``OR REPLACE`` clause causes the tag to be replaced if it already exists.
50+
* The optional ``IF NOT EXISTS`` clause causes the error to be suppressed if the tag already exists.
51+
* ``OR REPLACE`` and ``IF NOT EXISTS`` cannot be specified together.
52+
4353
Examples
4454
--------
4555

@@ -147,6 +157,34 @@ Create branch ``branch1`` from the ``users`` table for system version as of vers
147157

148158
ALTER TABLE users CREATE BRANCH 'branch1' FOR SYSTEM_VERSION AS OF 5 RETAIN INTERVAL 7 DAY WITH SNAPSHOT RETENTION 3 SNAPSHOTS INTERVAL 7 DAYS;
149159

160+
Create tag ``tag1`` from the ``users`` table::
161+
162+
ALTER TABLE users CREATE TAG 'tag1';
163+
164+
Create tag ``tag1`` from the ``users`` table only if it doesn't already exist::
165+
166+
ALTER TABLE users CREATE TAG IF NOT EXISTS 'tag1';
167+
168+
Create or replace tag ``tag1`` from the ``users`` table::
169+
170+
ALTER TABLE users CREATE OR REPLACE TAG 'tag1';
171+
172+
Create tag ``tag1`` from the ``users`` table for system version as of version 5::
173+
174+
ALTER TABLE users CREATE TAG 'tag1' FOR SYSTEM_VERSION AS OF 5;
175+
176+
Create tag ``tag1`` from the ``users`` table for system version as of version 5, only if it doesn't exist::
177+
178+
ALTER TABLE users CREATE TAG IF NOT EXISTS 'tag1' FOR SYSTEM_VERSION AS OF 5;
179+
180+
Create or replace tag ``tag1`` from the ``users`` table for system time as of timestamp '2026-01-02 17:30:35.247 Asia/Kolkata'::
181+
182+
ALTER TABLE users CREATE OR REPLACE TAG 'tag1' FOR SYSTEM_TIME AS OF TIMESTAMP '2026-01-02 17:30:35.247 Asia/Kolkata';
183+
184+
Create tag ``tag1`` from the ``users`` table for system version as of version 5 with retention period of 30 days::
185+
186+
ALTER TABLE users CREATE TAG 'tag1' FOR SYSTEM_VERSION AS OF 5 RETAIN INTERVAL 30 DAY;
187+
150188
See Also
151189
--------
152190

presto-hive/src/main/java/com/facebook/presto/hive/security/LegacyAccessControl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ public void checkCanCreateBranch(ConnectorTransactionHandle transactionHandle, C
306306
{
307307
}
308308

309+
@Override
310+
public void checkCanCreateTag(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
311+
{
312+
}
313+
309314
@Override
310315
public void checkCanDropTag(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
311316
{

presto-hive/src/main/java/com/facebook/presto/hive/security/SqlStandardAccessControl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateRole;
6262
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateSchema;
6363
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateTable;
64+
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateTag;
6465
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateView;
6566
import static com.facebook.presto.spi.security.AccessDeniedException.denyCreateViewWithSelect;
6667
import static com.facebook.presto.spi.security.AccessDeniedException.denyDeleteTable;
@@ -288,6 +289,24 @@ public void checkCanCreateBranch(ConnectorTransactionHandle transaction, Connect
288289
}
289290
}
290291

292+
@Override
293+
public void checkCanCreateTag(ConnectorTransactionHandle transaction, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
294+
{
295+
MetastoreContext metastoreContext = new MetastoreContext(
296+
identity, context.getQueryId().getId(),
297+
context.getClientInfo(),
298+
context.getClientTags(),
299+
context.getSource(),
300+
Optional.empty(),
301+
false,
302+
HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER,
303+
context.getWarningCollector(),
304+
context.getRuntimeStats());
305+
if (!isTableOwner(transaction, identity, metastoreContext, tableName)) {
306+
denyCreateTag(tableName.toString());
307+
}
308+
}
309+
291310
@Override
292311
public void checkCanDropTag(ConnectorTransactionHandle transaction, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
293312
{

presto-hive/src/main/java/com/facebook/presto/hive/security/SystemTableAwareAccessControl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ public void checkCanCreateBranch(ConnectorTransactionHandle transactionHandle, C
306306
delegate.checkCanCreateBranch(transactionHandle, identity, context, tableName);
307307
}
308308

309+
@Override
310+
public void checkCanCreateTag(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
311+
{
312+
delegate.checkCanCreateTag(transactionHandle, identity, context, tableName);
313+
}
314+
309315
@Override
310316
public void checkCanDropTag(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, AccessControlContext context, SchemaTableName tableName)
311317
{

0 commit comments

Comments
 (0)