SnowConvert AI - Paramètres des fonctions de prévisualisation

Paramètres des fonctions de prévisualisation

Les paramètres des fonctions de prévisualisation dans SnowConvert AI vous permettent d’activer des conversions qui utilisent des fonctions de prévisualisation publique Snowflake. En saisissant l’un des indicateurs disponibles dans la zone de texte, SnowConvert AI peut générer du code qui tire parti des fonctions Snowflake qui sont actuellement en prévisualisation, plutôt que d’être limités aux fonctions Snowflake à disposition générale (GA).

![image](../../../../../../images/gestions/sc-assets/ConversionPreviewFlags.png « image »)

Avertissement

Les fonctions de prévisualisation sont des fonctionnalités de Snowflake qui sont disponibles à des fins d’évaluation et de test, mais qui ne sont pas encore mise à disposition générale (GA). Ces fonctions ne doivent pas être utilisées dans les systèmes de production. Pour plus de détails sur les fonctions de prévisualisation de Snowflake, voir les Conditions d’utilisation des fonctions de prévisualisation de Snowflake.

Comprendre les fonctions de prévisualisation de Snowflake

Les fonctions de prévisualisation de Snowflake sont de nouvelles fonctionnalités qui ont été implémentées et testées dans Snowflake, mais qui peuvent ne pas avoir une opérabilité complète ou la capacité de traiter des cas particuliers. Lorsque vous activez des fonctions de prévisualisation dans SnowConvert AI, le processus de conversion peut générer du code qui utilise ces fonctions de prévisualisation lorsqu’elles produisent de meilleurs résultats de conversion.

Comment utiliser les fonctions de prévisualisation

  1. Activer dans SnowConvert AI : Saisissez l’un des indicateurs disponibles dans la zone de texte des paramètres des fonctions de prévisualisation pour permettre à SnowConvert AI de générer du code en utilisant les fonctions de prévisualisation.

  2. Activer dans Snowflake : Assurez-vous que les fonctions de prévisualisation sont activées dans votre compte Snowflake à l’aide de fonctions système comme SYSTEM_ENABLE_PREVIEW_ACCESS

  3. Tester soigneusement : Testez toujours le code converti dans un environnement Snowflake de non-production lorsque vous utilisez des fonctions de prévisualisation.

Considérations importantes

  • Compatibilité de compte Snowflake : Votre compte Snowflake doit disposer de fonctions de prévisualisation activées pour utiliser le code généré.

  • Stabilité des fonctions : Les fonctions de prévisualisation de Snowflake peuvent changer de comportement ou être supprimées dans les futures versions de Snowflake

  • Restrictions de production : Le code utilisant des fonctions de prévisualisation ne doit pas être déployé dans des environnements Snowflake de production

  • Documentation : SnowConvert AI peut ajouter des commentaires indiquant que les fonctions de prévisualisation sont utilisées

Accéder aux paramètres des fonctions de prévisualisation

Pour configurer des fonctions de prévisualisation dans SnowConvert AI :

  1. Accédez à la section Paramètres de conversion dans l’interface de SnowConvert AI.

  2. Sélectionnez l’onglet ou la section Fonctions de prévisualisation.

  3. Saisissez l’un des indicateurs disponibles dans la zone de texte pour permettre à SnowConvert AI d’utiliser les fonctions de prévisualisation de Snowflake. Veuillez vérifier que chaque indicateur est orthographié correctement ; si un indicateur est mal orthographié, tous les indicateurs seront ignorés lors de la conversion.

  4. Procéder à la conversion - SnowConvert AI utilisera automatiquement les fonctions de prévisualisation lorsqu’elles améliorent les résultats de conversion.

Utilisation des fonctions de prévisualisation à partir de la CLI

Lorsque vous utilisez SnowConvert AI à partir de l’interface de ligne de commande (CLI), vous pouvez activer des fonctions de prévisualisation en utilisant l’argument --previewFlags. La valeur doit être entourée de guillemets et contenir les indicateurs au format suivant :

--previewFlags "\"--enableFlag1 --enableFlag2\""

Exemple :

snowct [command] --previewFlags "\"--enableFlag\"" [other arguments]

Pour plusieurs indicateurs :

snowct [command] --previewFlags "\"--enableFlag --enableAnotherFlag\"" [other arguments]

Meilleures pratiques

  • Comprendre les implications : Sachez que le code converti nécessitera l’activation des fonctions de prévisualisation de Snowflake.

Note

Pour obtenir les informations les plus récentes sur les fonctions de prévisualisation de Snowflake que SnowConvert AI peut utiliser, consultez les dernières notes de version de SnowConvert AI ou contactez l’assistance.

Activer les fonctions de prévisualisation :

La section suivante répertorie les indicateurs des fonctions de prévisualisation qui peuvent être saisis dans la zone de texte pour activer des fonctions de prévisualisation Snowflake spécifiques lors de la conversion. Chaque indicateur permet à SnowConvert AI d’utiliser des fonctionnalités de prévisualisation particulières de Snowflake.

--enableSnowScriptUDF

Obsolète depuis la version 1.19.7. Cette fonctionnalité est déjà mise à disposition générale

Cette option active SnowConvert AI pour traduire des fonctions définies par l’utilisateur, en tirant parti des fonctions de prévisualisation d’UDF SnowScript. Apprenez-en plus dans la documentation ici : UDFs Snowflake Scripting.

Disponible uniquement pour les langages suivants :

  • SQL Server

  • Azure Synapse.

--enableFormatSpecifiersPreview

This option enables SnowConvert AI to utilize new Snowflake date/time format specifiers that are currently in preview. These improvements in Snowflake’s formatting capabilities provide better translation accuracy for SQL Server date/time formatting functions.

Note

Numeric format specifiers are now GA. Advanced numeric format specifiers (P, N, custom % patterns, and TM9 grouping) are now translated by default without requiring this flag. The translations in the Numeric format specifiers (now default) section below are always active.

What This Flag Enables:

This preview feature introduces new date/time format elements in Snowflake’s TO_CHAR function, allowing SnowConvert AI to generate more accurate translations of SQL Server FORMAT() calls:

  1. New Date/Time Format Elements - Non-padded format specifiers (Y, MO, D, H24, H12, ME, S, P)

These are Snowflake improvements, not just SnowConvert AI translation features. Your Snowflake account must have these preview features enabled to execute the converted date/time code.

Note: To use date/time code generated with this flag, you must request access to these preview features in your Snowflake account. Submit your request using this form: Snowflake Format Improvements Preview Access Request

Date Format Specifiers (Preview)

This flag enables SnowConvert AI to use new Snowflake date/time format elements that support non-padded output, providing accurate translations of SQL Server’s custom single-character format specifiers.

New Snowflake Format Elements:

These format elements are new in Snowflake (in preview) and enable better migration from SQL Server:

  • Y - Year last 2 digits without padding (e.g., 25 from 2025, 5 from 2005)

  • MO - Month without padding (e.g., 3 for March)

  • D - Day without padding (e.g., 5 for the 5th day)

  • H24 - Hour in 24-hour format without padding (e.g., 14 for 2 PM)

  • H12 - Hour in 12-hour format without padding (e.g., 2 for 2 PM)

  • ME - Minute without padding (e.g., 7 for 07 minutes)

  • S - Second without padding (e.g., 3 for 03 seconds)

  • P - Single-character AM/PM indicator (e.g., A for AM, P for PM)

Translation Examples:

The following examples show how SQL Server FORMAT() patterns are translated to Snowflake using these new format elements:

SQL Server Code

SQL Server Output

Snowflake Translation

Snowflake Output

FORMAT(CAST('2025-03-05' AS DATE), '%M')

3

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05'), 'MO')

3

FORMAT(CAST('2025-03-05' AS DATE), '%d')

5

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05'), 'D')

5

FORMAT(CAST('2025-03-05' AS DATE), '%y')

25

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05'), 'Y')

25

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), '%H')

14

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'H24')

14

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), '%h')

2

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'H12')

2

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), '%m')

7

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'ME')

7

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), '%s')

3

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'S')

3

Combined Format Patterns:

SQL Server Code

SQL Server Output

Snowflake Translation

Snowflake Output

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), 'M/d/yyyy H:m:s')

3/5/2025 14:7:3

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'MO/D/YYYY H24:ME:S')

3/5/2025 14:7:3

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), 'M/d/yyyy h:m:s tt')

3/5/2025 2:7:3 PM

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'MO/D/YYYY H12:ME:S PM')

3/5/2025 2:7:3 PM

FORMAT(CAST('2025-03-05 14:07:03' AS DATETIME), 'h:m:s t')

2:7:3 P

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05 14:07:03'), 'H12:ME:S P')

2:7:3 P

FORMAT(CAST('2025-03-05' AS DATE), 'M/d/%y')

3/5/25

TO_CHAR(TO_TIMESTAMP_NTZ('2025-03-05'), 'MO/D/Y')

3/5/25

Key Points:

  • MO replaces SQL Server’s %M (uppercase M = month)

  • ME replaces SQL Server’s %m (lowercase m = minute)

  • H24 replaces SQL Server’s %H (uppercase H = 24-hour)

  • H12 replaces SQL Server’s %H (lowercase h = 12-hour)

  • P provides single-character AM/PM output (A or P)

  • All formats maintain SQL Server’s behavior of no leading zeros

Numeric format specifiers (now default)

The following numeric format translations are now applied by default without requiring the --enableFormatSpecifiersPreview flag. SnowConvert AI translates SQL Server’s percentage and number formatting patterns using Snowflake’s numeric format capabilities.

Percentage Formats (P and %):

SQL Server’s P format and custom % patterns automatically multiply values by 100 and add percentage symbols. The Snowflake translations use fixed-point formats with % symbols:

SQL Server Code

SQL Server Output

Snowflake Translation

Snowflake Output

FORMAT(0.1234, 'P')

12.34 %

TO_CHAR(0.1234, 'FM9,999,999,999,999.00%')

12.34 %

FORMAT(0.1234, 'P0')

12 %

TO_CHAR(0.1234, 'FM9,999,999,999,999%')

12 %

FORMAT(0.1234, 'P2')

12.34 %

TO_CHAR(0.1234, 'FM9,999,999,999,999.00%')

12.34 %

FORMAT(0.1234, '0.00%')

12.34%

TO_CHAR(0.1234, 'FM9999999999999.00%')

12.34%

FORMAT(0.1234, '#,#.00%')

12.34%

TO_CHAR(0.1234, 'FM9,999,999,999,999.00%')

12.34%

FORMAT(0.1234, '%0.00')

%12.34

TO_CHAR(0.1234, '%FM9999999999999.00')

%12.34

Number Formats (N):

SQL Server’s N format provides thousand separators and controlled decimal precision. The Snowflake translations use the enhanced TM9 format element with arguments:

SQL Server Code

SQL Server Output

Snowflake Translation

Snowflake Output

FORMAT(1234567.89, 'N')

1,234,567.89

TO_CHAR(1234567.89, 'TM9(2,3)')

1,234,567.89

FORMAT(1234567.89, 'N0')

1,234,568

TO_CHAR(1234567.89, 'TM9(0,3)')

1,234,568

FORMAT(1234567.89, 'N1')

1,234,567.9

TO_CHAR(1234567.89, 'TM9(1,3)')

1,234,567.9

FORMAT(1234567.89, 'N4')

1,234,567.8900

TO_CHAR(1234567.89, 'TM9(4,3)')

1,234,567.8900

FORMAT(-1234567.89, 'N2')

-1,234,567.89

TO_CHAR(-1234567.89, 'TM9(2,3)')

-1,234,567.89

TM9 Format Element Enhancement (Now Default)

The existing Snowflake TM9 format element has been enhanced to accept two optional arguments for better control over numeric formatting. This is a Snowflake improvement that enables better translations from SQL Server. These translations are now applied by default.

Syntax: TM9(fractional_digits, grouping_size)

Translation Examples:

SQL Server Code

Snowflake Translation

Input Value

Snowflake Output

Description

FORMAT(x, 'N2')

TO_CHAR(x, 'TM9(2,3)')

1234.56789

1,234.57

2 decimals with grouping

FORMAT(x, 'N0')

TO_CHAR(x, 'TM9(0,3)')

1234.56789

1,235

No decimals, rounded

FORMAT(x, 'N4')

TO_CHAR(x, 'TM9(4,3)')

1234567.89

1,234,567.8900

4 decimals with grouping

(Direct usage)

TO_CHAR(x, 'TM9(ALL,3)')

1234.56789

1,234.56789

All decimals, grouped

(Direct usage)

TO_CHAR(x, 'TM9(3)')

1234.56789

1234.568

3 decimals, no grouping

(Direct usage)

TO_CHAR(x, 'TM9')

1234.56789

1234.56789

All decimals, no grouping (default)

Behavior Details:

-- Snowflake examples with TM9 enhancement
SELECT 
    TO_CHAR(1234.56789, 'TM9')           AS default_format,    -- 1234.56789
    TO_CHAR(1234.56789, 'TM9(2)')        AS two_decimals,      -- 1234.57
    TO_CHAR(1234.56789, 'TM9(0)')        AS integer_only,      -- 1235
    TO_CHAR(1234.56789, 'TM9(ALL, 3)')   AS all_with_group,    -- 1,234.56789
    TO_CHAR(1234567.89, 'TM9(3, 3)')     AS three_with_group,  -- 1,234,567.890
    TO_CHAR(-1234567.89, 'TM9(2, 3)')    AS negative_value;    -- -1,234,567.89

Available for: SQL Server only

--UseIntervalDatatype

This option enables SnowConvert AI to translate INTERVAL data types to native Snowflake INTERVAL types (INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND) instead of converting them to VARCHAR. This takes advantage of the Snowflake INTERVAL data type that is currently in public preview. Learn more from the documentation here: Snowflake INTERVAL Data Type.

For a comprehensive reference on how interval transformations work across all languages, see the Interval Data Types translation reference.

What This Flag Enables:

  1. Native INTERVAL column types - INTERVAL columns in CREATE TABLE are preserved as Snowflake INTERVAL types instead of being converted to VARCHAR(30)

  2. Interval literal normalization - Dialect-specific interval literal syntax is normalized to Snowflake-compatible INTERVAL literals

  3. Interval arithmetic preservation - Datetime subtraction expressions that produce intervals are transformed to use Snowflake’s native interval output

  4. CAST to INTERVAL - CAST expressions targeting interval types are preserved

Translation Examples:

Source SQL

Without Flag

With --UseIntervalDatatype

col1 INTERVAL DAY TO SECOND (Oracle, Teradata)

col1 VARCHAR(30) + SSC-EWI-0036

col1 INTERVAL DAY TO SECOND

col1 INTERVAL (BigQuery, PostgreSQL)

col1 VARCHAR(30) + SSC-EWI-0036

col1 INTERVAL DAY TO SECOND + SSC-FDM-0042

SELECT INTERVAL '5-10' YEAR TO MONTH

SELECT '5-10' (string literal)

SELECT INTERVAL '5-10' YEAR TO MONTH

SELECT (ts1 - ts2) DAY TO SECOND

Not transformed to interval

SELECT ts1 - ts2 INTERVAL DAY TO SECOND

Known Limitations:

When this flag is enabled, SnowConvert AI emits warnings for scenarios where Snowflake does not yet fully support INTERVAL:

  • Dynamic Tables (SSC-EWI-0118): Snowflake does not support INTERVAL columns in Dynamic Tables

  • UDFs and Snowflake Scripting (SSC-EWI-0117): Snowflake does not support the INTERVAL data type in UDF/procedure parameters, return types, or variable declarations

  • Semi-structured types (SSC-EWI-0116): Snowflake does not support INTERVAL values inside VARIANT, ARRAY, or other semi-structured type columns

  • Qualifier normalization (SSC-FDM-0042): For languages with unqualified or mixed INTERVAL types, the qualifier is changed to DAY TO SECOND because Snowflake does not support mixing year-to-month and day-to-second time parts

Available for: All supported languages (Teradata, Oracle, SQL Server, Azure Synapse, BigQuery, Hive, Spark, Databricks, PostgreSQL, Greenplum, Netezza, Redshift, Vertica, DB2)