エイリアス

用途

view: view_name {
  dimension: field_name {
    alias: [old_field_name, old_field_name, ...]
  }
}
階層
alias
使用可能なフィールドタイプ
ディメンション、ディメンショングループ、メジャー、フィルタ、パラメータ

許可
フィールド名の角かっこで囲まれたリスト

定義

alias パラメータは、クエリの URL に表示される可能性のあるフィールドに別名を付与するものです。モデルのフィールド名が変更されても、既存のクエリ URL を機能させ続けたい場合に有効です。

次の例は、count を参照する既存のクエリを中断することなく、count という名前のフィールドを新しい名前 number_of_items に変更する方法を示しています。

measure: number_of_items {  # the new name
  alias: [count]            # the old name
  type: count
}

フィールドの名前を複数回変更する場合は、複数のエイリアスを指定することもできます。たとえば、前の例の number_of_items フィールドの名前を number_of_order_items に変更した場合は、次のように使用できます。

measure: number_of_order_items {   # the new name
  alias: [count, number_of_items]  # the old names
  type: count
}

ディメンショングループで alias を使用するには、ディメンショングループ内のすべてのフィールドではなく、ディメンショングループ名を変更します。たとえば、ディメンショングループ created_date の名前を order_date に変更するには:

dimension_group: order_date {  # the new name
  alias: [created_date]        # the old name
  type: time
  timeframes: [time, hour, date, week, month, year, hour_of_day, day_of_week, month_num, raw]
  sql: ${TABLE}.created_at ;;
}

alias は、URL の機能を維持するためにのみ使用されます。LookML でフィールドを参照する際には使用しないでください。次に例を示します。

measure: number_of_items {
  alias: [count]
  type: count
}
measure: percent_items_sold {
  sql: ${sold_items} / ${number_of_items} ;; # will work because there
  type: number                               # is a measure named number_of_items
}
measure: percent_items_sold {
  sql: ${sold_items} / ${count} ;; # will NOT work because you
  type: number                     # should not use alias names in LookML
}

知っておくべきこと

別のフィールドですでに使用されている名前でフィールドを alias すると、LookML バリデータがエラーを返します。