alias

사용

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 검사기에서 오류가 반환됩니다.