Back to home page

OSCL-LXR

 
 

    


0001 -- Mixed inputs (output type is string)
0002 SELECT elt(2, col1, col2, col3, col4, col5) col
0003 FROM (
0004   SELECT
0005     'prefix_' col1,
0006     id col2,
0007     string(id + 1) col3,
0008     encode(string(id + 2), 'utf-8') col4,
0009     CAST(id AS DOUBLE) col5
0010   FROM range(10)
0011 );
0012 
0013 SELECT elt(3, col1, col2, col3, col4) col
0014 FROM (
0015   SELECT
0016     string(id) col1,
0017     string(id + 1) col2,
0018     encode(string(id + 2), 'utf-8') col3,
0019     encode(string(id + 3), 'utf-8') col4
0020   FROM range(10)
0021 );
0022 
0023 -- turn on eltOutputAsString
0024 set spark.sql.function.eltOutputAsString=true;
0025 
0026 SELECT elt(1, col1, col2) col
0027 FROM (
0028   SELECT
0029     encode(string(id), 'utf-8') col1,
0030     encode(string(id + 1), 'utf-8') col2
0031   FROM range(10)
0032 );
0033 
0034 -- turn off eltOutputAsString
0035 set spark.sql.function.eltOutputAsString=false;
0036 
0037 -- Elt binary inputs (output type is binary)
0038 SELECT elt(2, col1, col2) col
0039 FROM (
0040   SELECT
0041     encode(string(id), 'utf-8') col1,
0042     encode(string(id + 1), 'utf-8') col2
0043   FROM range(10)
0044 );