github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/logictest/testdata/logic_test/target_names (about)

     1  # LogicTest: local
     2  
     3  statement ok
     4  CREATE TABLE t(a INT[], t STRING);
     5  
     6  # Simple expressions get the underlying column name as name.
     7  query ITTIIT colnames
     8  SELECT *, a, a[0], (((((((((a))))))))), t COLLATE "en_US" FROM t
     9  ----
    10  a t a a a t
    11  
    12  # Functions and function-like expressions get the function name.
    13  query ITTTTBTT colnames
    14  SELECT array_length(a, 1),
    15         nullif(a, a),
    16         row(1,2,3),
    17         coalesce(a,a),
    18         iferror(a, a),
    19         iserror(a),
    20         if(true, a, a),
    21         current_user
    22  FROM t
    23  ----
    24  array_length  nullif  row  coalesce  iferror  iserror if current_user
    25  
    26  # Literals get named just "?column?" except for true/false which are handled specially.
    27  query ITRBBT colnames
    28  SELECT 123, '123', 123.0, TRUE, FALSE, NULL
    29  ----
    30  ?column?  ?column?  ?column?  bool  bool   ?column?
    31  123       123       123.0     true  false  NULL
    32  
    33  # Casts get the underlying expression name if there is one,
    34  # otherwise the name of the type.
    35  query IITI colnames
    36  SELECT t::INT, '123'::INT, t:::STRING, '123':::INT FROM t
    37  ----
    38  t  int8  t  int8
    39  
    40  # Field access gets the field name.
    41  query T colnames
    42  SELECT (pg_get_keywords()).word FROM t
    43  ----
    44  word
    45  
    46  # Array stuff is called "array"
    47  query TT colnames
    48  SELECT array[1,2,3], array(select 1)
    49  ----
    50  array    array
    51  {1,2,3}  {1}
    52  
    53  # EXISTS in subqueries called "exists"
    54  query B colnames
    55  SELECT EXISTS(SELECT * FROM t)
    56  ----
    57  exists
    58  false
    59  
    60  # CASE gets named after the ELSE branch, otherwise "case"
    61  query IIIII colnames
    62  SELECT CASE 1 WHEN 2 THEN 3 END,
    63         CASE 1 WHEN 2 THEN 3 ELSE a[0] END,
    64         CASE 1 WHEN 2 THEN 3 ELSE length(t) END,
    65         CASE 1 WHEN 2 THEN 3 ELSE (t||'a')::INT END,
    66         CASE 1 WHEN 2 THEN 3 ELSE 4 END
    67    FROM t
    68  ----
    69  case  a  length  case  case
    70  
    71  # Subqueries get named after the expression.
    72  query III colnames
    73  SELECT (SELECT 123 AS a),
    74         (VALUES (cos(1)::INT)),
    75         (SELECT cos(0)::INT)
    76  ----
    77  a   column1 cos
    78  123 0       1