本頁面說明探索中的
case_sensitive參數。
case_sensitive也可做為模型的一部分,詳情請參閱「case_sensitive(適用於模型)」參數說明文件頁面。
case_sensitive也可以做為維度的一部分,詳情請參閱case_sensitive(適用於欄位) 參數說明文件頁面。
用量
explore: explore_name {
case_sensitive: yes
}
|
階層
case_sensitive |
預設值
yes (如果資料庫方言支援該參數)
接受
布林值 (yes 或 no)
|
定義
case_sensitive 決定在特定探索中,篩選器是否區分大小寫。所有與探索相關的篩選器都會受到影響,包括在探索 UI、資訊主頁 UI 和 filters 參數中新增的篩選器。
根據預設,case_sensitivity 為開啟狀態,且篩選器會區分大小寫。不過,部分方言不支援這項參數,詳情請參閱本頁的「部分 SQL 方言不支援 case_sensitive」一節。
case_sensitive 的運作方式是調整 Looker 生成的 SQL WHERE 子句。啟用 case_sensitive 時,篩選條件會以 = 或 LIKE 表示,例如:
WHERE name = 'bob'
WHERE name LIKE '%bob%'
case_sensitive 關閉時,篩選器會以 ILIKE (或等效值) 表示,例如:
WHERE name ILIKE 'bob'
範例
將「Product」探索的所有篩選器設為區分大小寫:
explore: product {
case_sensitive: yes
}
讓「客戶」探索的所有篩選器都不區分大小寫:
explore: customer {
case_sensitive: no
}
常見挑戰
部分 SQL 方言不支援 case_sensitive
根據預設,case_sensitivity 為開啟狀態,且篩選器會區分大小寫。如果 SQL 方言不支援 case_sensitive 參數,是否區分大小寫會因資料庫設定而異,通常不區分大小寫。
如要讓 Looker 支援 Looker 專案中的case_sensitive,資料庫方言也必須支援。下表列出最新版 Looker 中支援 case_sensitive 的方言:
| 方言 | 是否支援? |
|---|---|
| Actian Avalanche | |
| Amazon Athena | |
| Amazon Aurora MySQL | |
| Amazon Redshift | |
| Amazon Redshift 2.1+ | |
| Amazon Redshift Serverless 2.1+ | |
| Apache Druid | |
| Apache Druid 0.13.x - 0.17.x | |
| Apache Druid 0.18+ | |
| Apache Hive 2.3+ | |
| Apache Hive 3.1.2+ | |
| Apache Spark 3+ | |
| ClickHouse | |
| ClickHouse 26+ | |
| Cloudera Impala 3.1+ | |
| Cloudera Impala 3.1+ with Native Driver | |
| Cloudera Impala with Native Driver | |
| DataVirtuality | |
| Databricks | |
| Denodo 7 | |
| Denodo 8 & 9 | |
| Dremio | |
| Dremio 11+ | |
| Dremio 26+ with Arrow Flight SQL | |
| Exasol | |
| Google BigQuery Legacy SQL | |
| Google BigQuery Standard SQL | |
| Google Cloud AlloyDB for PostgreSQL | |
| Google Cloud PostgreSQL | |
| Google Cloud SQL | |
| Google Spanner | |
| Greenplum | |
| HyperSQL | |
| IBM Netezza | |
| MariaDB | |
| Microsoft Azure PostgreSQL | |
| Microsoft Azure SQL Database | |
| Microsoft Azure Synapse Analytics | |
| Microsoft SQL Server 2008+ | |
| Microsoft SQL Server 2012+ | |
| Microsoft SQL Server 2016 | |
| Microsoft SQL Server 2017+ | |
| MongoBI | |
| MongoSQL | |
| MySQL | |
| MySQL 8.0.12+ | |
| Oracle | |
| Oracle ADWC | |
| PostgreSQL 9.5+ | |
| PostgreSQL pre-9.5 | |
| PrestoDB | |
| PrestoSQL | |
| SAP HANA | |
| SAP HANA 2+ | |
| SingleStore | |
| SingleStore 7+ | |
| Snowflake | |
| Teradata | |
| Trino | |
| Vector | |
| Vertica |
注意事項
您可以在 MySQL 中建立區分大小寫的搜尋
雖然 MySQL 不支援 case_sensitive 參數,但您仍可在 MySQL 中建立區分大小寫的搜尋。在 MySQL 中,某些資料型別 (稱為二進位字串) 會將文字儲存為一系列數字。文字大小寫會影響使用的數字。因此,如果將文字轉換為二進位字串,即可進行區分大小寫的搜尋。例如:
dimension: will_NOT_be_case_sensitive {
sql: ${TABLE}.something ;;
}
dimension: will_be_case_sensitive {
sql: CAST(${TABLE}.something AS BINARY) ;;
}