PRAGMA

Definition

Redefinition of settings.

Syntax

PRAGMA x.y = "z"; or PRAGMA x.y("z", "z2", "z3");:

  • x: (optional) The category of the setting.

  • y: The name of the setting.

  • z: (optional for flags) The value of the setting. The following suffixes are acceptable:

    • Kb, Mb, Gb: For the data amounts.
    • sec, min, h, d: For the time values.

Examples

PRAGMA AutoCommit;
PRAGMA TablePathPrefix = "home/yql";
PRAGMA Warning("disable", "1101");

With some exceptions, you can return the settings values to their default states using PRAGMA my_pragma = default;.

For the full list of available settings, see the table below.

Scope

Unless otherwise specified, a pragma affects all the subsequent expressions up to the end of the module where it's used. If necessary and logically possible, you can change the value of this setting several times within a given query to make it different at different execution steps.

There are also special scoped pragmas with the scope defined by the same rules as the scope of named expressions. Unlike scoped pragmas, regular pragmas can only be used in the global scope (not inside lambda functions, ACTION, etc.).

Global

AutoCommit

Value type Default
Flag false

Automatically run COMMIT after every statement.

TablePathPrefix

Value type Default
String

Add the specified prefix to the cluster table paths. It uses standard file system path concatenation, supporting parent folder .. referencing and requiring no trailing slash. For example,

PRAGMA TablePathPrefix = "home/yql"; SELECT * FROM test;

The prefix is not added if the table name is an absolute path (starts with /).

UseTablePrefixForEach

Value type Default
Flag false

EACH uses TablePathPrefix for each list item.

Warning

Value type Default
1. Action
2. Warning code or "*"

Action:

  • disable: Disable.
  • error: Treat as an error.
  • default: Revert to the default behavior.

The warning code is returned with the text itself (it's displayed on the right side of the web interface).

Example

PRAGMA Warning("error", "*");
PRAGMA Warning("disable", "1101");
PRAGMA Warning("default", "4503");

In this case, all the warnings are treated as errors, except for the warning 1101 (that will be disabled) and 4503 (that will be processed by default, that is, remain a warning). Since warnings may be added in new YQL releases, use PRAGMA Warning("error", "*"); with caution (at least cover such queries with autotests).

SimpleColumns

SimpleColumns / DisableSimpleColumns

Value type Default
Flag true

When you use SELECT foo.* FROM ... AS foo, remove the foo. prefix from the names of the result columns.

It can be also used with a JOIN, but in this case it may fail in the case of a name conflict (that can be resolved by using WITHOUT and renaming columns). For JOIN in SimpleColumns mode, an implicit Coalesce is made for key columns: the query SELECT * FROM T1 AS a JOIN T2 AS b USING(key) in the SimpleColumns mode works same as SELECT a.key ?? b.key AS key, ... FROM T1 AS a JOIN T2 AS b USING(key).

CoalesceJoinKeysOnQualifiedAll

CoalesceJoinKeysOnQualifiedAll / DisableCoalesceJoinKeysOnQualifiedAll

Value type Default
Flag true

Controls implicit Coalesce for the key JOIN columns in the SimpleColumns mode. If the flag is set, the Coalesce is made for key columns if there is at least one expression in the format foo.* or * in SELECT: for example, SELECT a.* FROM T1 AS a JOIN T2 AS b USING(key). If the flag is not set, then Coalesce for JOIN keys is made only if there is an asterisk '*' after SELECT

StrictJoinKeyTypes

StrictJoinKeyTypes / DisableStrictJoinKeyTypes

Value type Default
Flag false

If the flag is set, then JOIN will require strict matching of key types.
By default, JOIN preconverts keys to a shared type, which might result in performance degradation.
StrictJoinKeyTypes is a scoped setting.

AnsiInForEmptyOrNullableItemsCollections

Value type Default
Flag false

This pragma brings the behavior of the IN operator in accordance with the standard when there's NULL in the left or right side of IN. The behavior of IN when on the right side there is a Tuple with elements of different types also changed. Examples:

1 IN (2, 3, NULL) = NULL (was Just(False))
NULL IN () = Just(False) (was NULL)
(1, null) IN ((2, 2), (3, 3)) = Just(False) (was NULL)

For more information about the IN behavior when operands include NULLs, see here. You can explicitly select the old behavior by specifying the pragma DisableAnsiInForEmptyOrNullableItemsCollections. If no pragma is set, then a warning is issued and the old version works.

AnsiRankForNullableKeys

Value type Default
Flag false

Aligns the RANK/DENSE_RANK behavior with the standard if there are optional types in the window sort keys or in the argument of such window functions. It means that:

  • The result type is always Uint64 rather than Uint64?.
  • NULLs in keys are treated as equal to each other (the current implementation returns NULL).

You can explicitly select the old behavior by using the DisableAnsiRankForNullableKeys pragma. If no pragma is set, then a warning is issued and the old version works.

AnsiCurrentRow

Value type Default
Flag false

Aligns the implicit setting of a window frame with the standard if there is ORDER BY.
If AnsiCurrentRow is not set, then the (ORDER BY key) window is equivalent to (ORDER BY key ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW).
The standard also requires that this window behave as (ORDER BY key RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW).
The difference is in how CURRENT ROW is interpreted. In ROWS mode CURRENT ROW is interpreted literally: the current row in a partition.
In RANGE mode, the end of the CURRENT ROW frame means "the last row in a partition with a sort key equal to the current row".

AnsiOrderByLimitInUnionAll

Value type Default
Flag false

Aligns the UNION ALL behavior with the standard if there is ORDER BY/LIMIT/DISCARD/INSERT INTO in the combined subqueries. It means that:

  • ORDER BY/LIMIT/INSERT INTO are allowed only after the last subquery.
  • DISCARD is allowed only before the first subquery.
  • The specified operators apply to the UNION ALL result (unlike the current behavior when they apply only to the subquery).
  • To apply an operator to a subquery, enclose the subquery in parentheses.

You can explicitly select the old behavior by using the DisableAnsiOrderByLimitInUnionAll pragma. If no pragma is set, then a warning is issued and the old version works.

OrderedColumns

OrderedColumns/DisableOrderedColumns

Output the column order in SELECT/JOIN/UNION ALL and preserve it when writing the results. The order of columns is undefined by default.

PositionalUnionAll

Enable the standard column-by-column execution for UNION ALL. This automatically enables
ordered columns.

RegexUseRe2

Value type Default
Flag false

Use Re2 UDF instead of Pcre to execute SQL the REGEX,MATCH,RLIKE statements. Re2 UDF can properly handle Unicode characters, unlike the default Pcre UDF.

ClassicDivision

Value type Default
Flag true

In the classical version, the result of integer division remains integer (by default).
If disabled, the result is always Double.
ClassicDivision is a scoped setting.

UnicodeLiterals

UnicodeLiterals/DisableUnicodeLiterals

Value type Default
Flag false

When this mode is enabled, string literals without suffixes like "foo"/'bar'/@@multiline@@ will be of type Utf8, when disabled - String.
UnicodeLiterals is a scoped setting.

WarnUntypedStringLiterals

WarnUntypedStringLiterals/DisableWarnUntypedStringLiterals

Value type Default
Flag false

When this mode is enabled, a warning will be generated for string literals without suffixes like "foo"/'bar'/@@multiline@@. It can be suppressed by explicitly choosing the suffix s for the String type, or u for the Utf8 type.
WarnUntypedStringLiterals is a scoped setting.

AllowDotInAlias

Value type Default
Flag false

Enable dot in names of result columns. This behavior is disabled by default, since the further use of such columns in JOIN is not fully implemented.

WarnUnnamedColumns

Value type Default
Flag false

Generate a warning if a column name was automatically generated for an unnamed expression in SELECT (in the format column[0-9]+).

GroupByLimit

Value type Default
Positive number 32

Increasing the limit on the number of dimensions in GROUP BY.

GroupByCubeLimit

Value type Default
Positive number 5

Increasing the limit on the number of dimensions in GROUP BY.

Use this option with care, because the computational complexity of the query grows exponentially with the number of dimensions.

Yson

Managing the default behavior of Yson UDF, for more information, see the documentation and, in particular, Yson::Options.

yson.AutoConvert

Value type Default
Flag false

Automatic conversion of values to the required data type in all Yson UDF calls, including implicit calls.

yson.Strict

Value type Default
Flag true

Strict mode control in all Yson UDF calls, including implicit calls. If the value is omitted or is "true", it enables the strict mode. If the value is "false", it disables the strict mode.

yson.DisableStrict

Value type Default
Flag false

An inverted version of yson.Strict. If the value is omitted or is "true", it disables the strict mode. If the value is "false", it enables the strict mode.

Previous