Перейти к основному содержимому

Parquet-файлы

Начиная с версии QS August 2023, Qlik доработал поддержку .parquet-файлов (подробнее)

Где применять

Меньший размер - очевидно, ибо в нём только сжатые данные, и в отличие от QVD - нет индексов. Поэтому нет и не может быть Optimized load. Ибо оптимизированное чтение - это чтение с готовыми индексами, без необходимости их перестроения. Поэтому по скорости чтения QVD всегда будет быстрее, т.к. чтение из любых других источников обязательно требует доп. расходы на построение индексов.

Максимальную скорость чтения из parquet можно получить не просто грузя из этого формата в обычной файловой системе последовательного чтения, а при наличии соответствующей инфраструктуры, за счет использования специализированных файловых систем, работающих в режиме распределенного партиционированного чтения (hadoop).

С точки зрения сценариев:

  1. Потенциальная экономия ресурсов на преобразованиях из источников parquet в формат QVD там, где это нецелесообразно

  2. Возможность работы с действительно безразмерными источниками, не зависящими от ресурсов серверов Qlik, т.к. файл parquet может создаваться и дополняться в любых объемах не только Qlik-ом, но и любыми сторонними системами, понимающими этот открытый формат. Польза от таких данные может быть получена в сценариях ODAG/Dynamic Views

  3. Сценарии ML, в которых данные предподготовленные Qlik-ом могут быть "съедены" сторонними системами, например, тот же Python

Как включить поддержку Parquet-файлов

To enable parquet files, they will need to be allowed as sources. We will use QlikSenseCLI in our example. QlikSenseCLI is shipped with Qlik Sense Enterprise on Windows since May 2023.

  • Open Powershell ISE as administrator
  • Import the QlikSenseCLI module in the current Powershell session:
    • Open the script C:\Program Files\Qlik\Sense\Tools\qlik-installation-tools
    • Run ImportQlikSenseCLIModule.ps1
    • This will print an about API output on successful run:
SchemaPath : About
BuildVersion : 31.34.0.0
BuildDate : 6/13/2023 10:08:17 AM
DatabaseProvider : Devart.Data.PostgreSql
NodeType : Central
SharedPersistence : True
RequiresBootstrap : False
SingleNodeOnly : False
ExtensionData :
  • Run the Parquet Whitelist Script: AddParquetExtentionWhitelistTable.ps1

You can now use parquet files in existing apps.

Тесты размера файлов

размеры parquet файлов

Как минимум, играя с разными вариантами компрессии (на фото слева, после даты - названия алгоритмов сжатия parquet), можно получить на примере моего файла сжатие данных в ~28%, т.е. размер parquet файла на 28% меньше, чем QVD.

Справка из документации

Storing in Parquet files

Parquet is a strongly typed file format, where each field contains a single specific type of data (such as in32, double, timestamp, or text). Qlik Sense stores internal data as a loosely typed dual, where data from difference sources can be mixed into the same fields. As only one part of the dual can be stored in each field in Parquet, it is important to know what each field contains. By default, Qlik Sense uses the field type to determine how the field should be stored. When storing data in Parquet files in a specific format, you must specify what type of data your fields are when loading them. If you try to store data into incompatible fields in a Parquet file, such as numbers in a text field or text in a timestamp field, you will end up with null values.

When loading data you intend to store in Parquet, it is possible to change the default behavior. You can either format it to change your data type or tag it to force specific column types in Parquet.

Formatting data for storage in Parquet

You can use Qlik Sense formatting functions to classify your data. For example, Text(), Num(), Interval(), or Timestamp() can enforce data formats when storing data in Parquet. Qlik Sense can store data into almost 20 data types depending on field attributes and automatic field tags. For more information, see Interpretation functions

Example: Formatting data with Num() and Text()

The following example demonstrates preparing data for storage in Parquet. Num() is applied to the num field. Text() is applied to both text and mixed. In the case of mixed, Text() prevents it from being treated like a number field in Parquet and having the text values changed to null values.

Data:
LOAD * INLINE [
num, text, mixed
123.321, abc, 123
456.654, def, xyz
789.987, ghi, 321
];

Format:
NoConcatenate
LOAD num, text, Text(mixed) as mixed RESIDENT Data;
STORE Format INTO [lib://DataFiles/Tmp.parquet] (parquet);

Tagging data for storage in Parquet

You tag your data with $parquet tags to force specific column types when storing data in Parquet. Each data type can be enforced by adding the corresponding control tag. For example, to store a field as INT32 in Parquet, tag it with $parquet-int32 in the load script. Depending on the data type, either the string or the numerical representation of the dual data will be stored.

The following Parqeut control tags can be used to tag fields for storing in Parquet files.

Parquet control tags

Control tagDualPhysical typeLogical typeConverted type
$parquet-booleanNumberBOOLEANNONENONE
$parquet-int32NumberINT32NONENONE
$parquet-int64NumberINT64NONENONE
$parquet-floatNumberFLOATNONENONE
$parquet-doubleNumberDOUBLENONENONE
$parquet-bytearrayStringBYTE_ARRAYNONEUTF8
$parquet-bytearrayfixNumberFIXED_LEN_BYTE_ARRAYNONEDECIMAL
$parquet-decimalNumberINT64DECIMALDECIMAL
$parquet-dateNumberINT32DATEDATE
$parquet-timeNumberINT64TIMETIME_MICROS
$parquet-timestampNumberINT64TIMESTAMPTIMESTAMP_MICROS
$parquet-stringStringBYTE_ARRAYSTRINGUTF8
$parquet-enumStringBYTE_ARRAYENUMENUM
$parquet-intervalNumberFIXED_LEN_BYTE_ARRAYINTERVALINTERVAL
$parquet-jsonStringBYTE_ARRAYJSONJSON
$parquet-bsonStringBYTE_ARRAYBSONBSON
$parquet-uuidStringFIXED_LEN_BYTE_ARRAYUUIDNONE

Example: Tagging data for storage in Parquet

In this example, two tags are used to define the data for Parquet. The field num is tagged with $parquet-int32 to define it as a number field that will be set as INT32 in Parquet.

Data:

Data:
LOAD * INLINE [
num, text,
123.321, abc
456.654, def
789.987, ghi
];
TAG num WITH '$parquet-int32';
STORE Data INTO [lib://DataFiles/Tmp.parquet] (parquet);

Источники