Snowpark Migration Accelerator : Valeurs¶
Description¶
Crée une table temporaire dans la requête qui peut être utilisée immédiatement. Pour plus d’informations, voir Référence linguistique Databricks SQL VALUES.
La sous-clause VALUES de la clause FROM d’une instruction SELECT vous permet de définir un ensemble de valeurs fixes pour créer un nombre spécifique de lignes. (Référence linguistique Snowflake SQL VALUES)
Syntaxe¶
VALUES {expression | ( expression [, ...] ) } [, ...] [table_alias]
SELECT expression [, ...] [table_alias]
SELECT ...
FROM ( VALUES ( <expr> [ , <expr> [ , ... ] ] ) [ , ( ... ) ] ) [ [ AS ] <table_alias> [ ( <column_alias> [, ... ] ) ] ]
[ ... ]
Modèles d’échantillons de sources¶
Données de configuration¶
Databricks¶
CREATE TEMPORARY VIEW number1(c) AS VALUES (3), (1), (2), (2), (3), (4);
Snowflake¶
CREATE TEMPORARY TABLE number1(c int);
INSERT INTO number1 VALUES (3), (1), (2), (2), (3), (4);
Code du modèle¶
Databricks¶
-- single row, without a table alias
> VALUES ("one", 1);
one 1
-- Multiple rows, one column
> VALUES 1, 2, 3;
1
2
3
-- three rows with a table alias
> SELECT data.a, b
FROM VALUES ('one', 1),
('two', 2),
('three', NULL) AS data(a, b);
one 1
two 2
three NULL
-- complex types with a table alias
> SELECT a, b
FROM VALUES ('one', array(0, 1)),
('two', array(2, 3)) AS data(a, b);
one [0, 1]
two [2, 3]
-- Using the SELECT syntax
> SELECT 'one', 2
one 2
c |
---|
3 |
1 |
2 |
4 |
Snowflake¶
-- single row, without a table alias
SELECT * FROM (VALUES ('one', 1));
-- Multiple rows, one column
SELECT * FROM (VALUES (1), (2), (3));
-- three rows with a table alias
SELECT a, b
FROM (VALUES ('one', 1),
('two', 2),
('three', NULL)) AS data(a, b);
-- complex types with a table alias
SELECT a, b
FROM
(VALUES ('one', '[0, 1]'),
('two', '[2, 3]')
) AS data(a, b);
-- Using the SELECT syntax
SELECT 'one', 2
c |
---|
3 |
1 |
2 |
4 |
Problèmes connus¶
Aucun problème n’a été trouvé