エイリアス

使用状況

ビュー: 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 バリデータからエラーが返されます。